watchkit - 'isReachable' is false when sending message from watch app to iOS app -


i want send instant message ios app watch app. implemented following code in xcode7 beta 4 version , keeping application in foreground in both simulators. here code implemented

in watchkit interfacecontroller

      -(void)willactivate      {         [super willactivate];         if ([wcsession issupported]) {             wcsession *session = [wcsession defaultsession];             session.delegate = self;             [session activatesession];         }     }  -(ibaction)buttonclicked {     nsdictionary *applicationdict = [[nsdictionary alloc] initwithobjects:@[@"hi"] forkeys:@[@"key"]];     if([[wcsession defaultsession] isreachable])     {         [[wcsession defaultsession] sendmessage:applicationdict                                    replyhandler:^(nsdictionary *reply) {                                         nslog(@"%@",reply);                                     }                                     errorhandler:^(nserror *error) {                                         nslog(@"%@",error);                                     }];     } }   

in ios app class

      -(void)viewdidload      {         [super viewdidload];         if ([wcsession issupported]){             wcsession *session = [wcsession defaultsession];             session.delegate = self;             [session activatesession];         }     }       -(void)session:(nonnull wcsession *)session      didreceivemessage:(nonnull nsdictionary *)message replyhandler:(nonnull void (^)(nsdictionary * __nonnull))replyhandler      {         dispatch_async(dispatch_get_main_queue(), ^{             self.testlbl.text = [message objectforkey:@"key"];             [self.view setneedsdisplay];         });     }  

do have use sendmessage apis? found them unreliable , unpredictable well. ended using applicationcontext api's. watch doesn't have reachable, if is, arrives immediately, if not reachable, gets delivered on app launch. each time update application context, overwrites previous version, might not looking for.


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -