-3

Now I'm developing apple watch extension and I use WatchConnectivity. Can I send message to ios app ios application make a request ?

Who can make a request to the server ios app or watch extension ?

P.S. Use AFNetworking to work with server.

Thanks

Cody
  • 1
  • 2

1 Answers1

1

You can use this method to send notification to ios App to make request

[[WCSession defaultSession] sendMessage:dictSendMessage replyHandler:^(NSDictionary<NSString *,id> * _Nonnull replyMessage) {
} errorHandler:^(NSError * _Nonnull error) {

    }];

And you can receive that notification with this delegate method in ios app

-(void)session:(WCSession *)session didReceiveMessage:(NSDictionary<NSString *,id> *)message replyHandler:(void (^)(NSDictionary<NSString *,id> * _Nonnull))replyHandler
{
}

Note : You can also request to server from watch app it self with the help of

NSURLSessionDataTask *taskDownload = [[NSURLSession sharedSession] dataTaskWithURL:url completionHandler:^(NSData *data, NSURLResponse *response, NSError *error)
    {
}];
// Start the task.
    [taskDownload resume];
Hitesh Sultaniya
  • 929
  • 1
  • 7
  • 12