objective c - watch os 2 not waking parent app and changing UITableView of parent -


i have watch app being updated watch os 2. sendmessage not wake parent app. according transition documentation how wake parent in background.

"the ios app considered reachable, , calling method watch app wakes ios app in background needed."

has had problem? way data have parent app open.

another weird thing watch app changes uitableview parent app. when -(ibaction)yesterdaysales:(id)sender called on watch, changes parent app uitableview instead of watch tableview.

interfacecontroller.m

#import "interfacecontroller.h" #import "myrowcontroller.h" #import "ftdateparser.h"  @import watchkit; #import <watchconnectivity/watchconnectivity.h>  @interface interfacecontroller() <wcsessiondelegate>  { iboutlet wkinterfacedevice *it; bool tday; iboutlet wkinterfacelabel *lblcompany; }  @end   @implementation interfacecontroller @synthesize mytable = _mytable; - (void)awakewithcontext:(id)context { [super awakewithcontext:context];  // configure interface objects here. if([wcsession issupported]){     wcsession *session = [wcsession defaultsession];     session.delegate = self;     [session activatesession]; }   //[self requestinfophone]; [self gettoday]; }  - (void)willactivate { // method called when watch view controller visible user     [super willactivate];    }  - (void)diddeactivate { // method called when watch view controller no longer visible [super diddeactivate];  }  -(void)requestinfophone{  nsdictionary *dic = @{@"request":@"ysales"};  [[wcsession defaultsession] sendmessage:dic                            replyhandler:^(nsdictionary *replyinfo){                                nslog(@"the reply: %@", replyinfo);                                nsdictionary *location = replyinfo;                                nsstring *name = location[@"label"];                                nsstring *totalsales = location[@"totalsales"];                                // nsstring *test2 = location[@"rowtext"];                                nsmutablearray *sales = [[nsmutablearray alloc]init];                                nsmutablearray *storenames = [[nsmutablearray alloc]init];                                sales = location[@"rowtext"];                                storenames = location[@"storenames"];                                [self loadtable:sales names:storenames company:name];                                [_labelname settext:name];                                [_labeltotalsales settext:totalsales];                                tday = yes;                            }                            errorhandler:^(nserror *error){                                nslog(@"%@", error);                            }  ];  }  -(void)loadtable:(nsmutablearray*)tester names:(nsmutablearray*)names company:(nsstring *)company{ [_mytable setnumberofrows:[tester count] withrowtype:@"row"];  [_labelname settext:company]; (int = 0; < [tester count]; i++) {     myrowcontroller *vc  = [_mytable rowcontrolleratindex:i]; [vc.testlabel settext:[ftdateparser currencyformat: tester[i]]];     [vc.namelabel settext:[ftdateparser parsename:names[i]]]; } [_mytable scrolltorowatindex:(0)]; } -(ibaction)yesterdaysales:(id)sender{ if (tday) {     [_ydaysales settitle:@"today sales"];     [self requestinfophone]; } else{     [_ydaysales settitle:@"yesterday sales"];     [self gettoday]; }  }    -(void)gettoday{  nsdictionary *dic = @{@"request":@"todaysales"};  [[wcsession defaultsession] sendmessage:dic                            replyhandler:^(nsdictionary *replyinfo){                                                                   nsdictionary *location = replyinfo;                                nsstring *name = location[@"label"];                                nsstring *totalsales = location[@"totalsales"];                                // nsstring *test2 = location[@"rowtext"];                                nsmutablearray *sales = [[nsmutablearray alloc]init];                                nsmutablearray *storenames = [[nsmutablearray alloc]init];                                sales = location[@"rowtext"];                                storenames = location[@"storenames"];                                [self loadtable:sales names:storenames company:name];                                [_labelname settext:name];                                [_labeltotalsales settext:totalsales];                                tday = yes;                            }                            errorhandler:^(nserror *error){                                nslog(@"%@", error);                            }  ];    } @end 

parent.m

-(void)setupappforwatch{ done = no; if([wcsession issupported]){     wcsession *session = [wcsession defaultsession];     session.delegate = self;     [session activatesession]; } }    -(void)session:(wcsession *)session didreceivemessage:(nsdictionary<nsstring *,id> *)message replyhandler:(void (^)(nsdictionary<nsstring *,id> * _nonnull))replyhandler{ /*uiapplication *application = [uiapplication sharedapplication];  __block uibackgroundtaskidentifier identifier = uibackgroundtaskinvalid; dispatch_block_t endblock = ^ {     if (identifier != uibackgroundtaskinvalid) {         [application endbackgroundtask:identifier];     }     identifier = uibackgroundtaskinvalid; };  identifier = [application beginbackgroundtaskwithexpirationhandler:endblock];*/  [self setupappforwatch]; [self getthedate]; startdate = todayday; enddate = tomorrow; //[self gettodaysalesforwatch]; nsstring *currency = [ftdateparser currencyformat:totalsales]; nsdictionary *dic = @{@"label": [nsstring stringwithformat:@"%@", @"town crier, inc."],                        @"totalsales": currency,                        @"rowtext": storesalesdata,//[nsstring stringwithformat:@"%@", currency]                        @"storenames":storenames                        };  nsstring *request = [message objectforkey:@"request"]; if ([request isequaltostring:@"todaysales"]) {     [self gettodaysalesforwatch]; } else if ([request isequaltostring:@"ysales"]){     [self connecttowebservice]; } if (done) {     replyhandler(dic); }  } 

edit:

maybe changes parent app happening before, didn't know cause app running in background. still can't wake parent app.

you don't link source of quote @ top of question must referring openparentapplication method of watchkit 1. devices running watchos 2.0 cannot call openparentapplication.

the method you're implementing in code in question wcsession, works immediate communication between watchkit app extension , ios app that both running @ same time. method not cause ios app launch, neither in background nor in foreground. other asynchronous communication methods must used if both apps not running @ time.


Comments