0

Suppose I have a Pro version of the watchOS app, and I want to redirect user to the App Store on the iPhone. How to achieve this?

I tried to use WatchConnectivity. In the iOS app I have the following code:

func session(_ session: WCSession, didReceiveMessage message: [String : Any]) {
    if message[.openProAppOnAppstoreMessageKey] != nil {
        // NOTE: Works only in foreground
        UIApplication.shared.openURL(.proApp)
    }
}

The problem is that this will work only if iOS app is in the foreground. While in the background, session(didReceiveMessage:) is called successfully, however openURL has no effect.

kelin
  • 11,323
  • 6
  • 67
  • 104

1 Answers1

1

There is no way to bring your iOS app to the foreground using WatchConnectivity and you cannot open any apps from the background. The user needs to open your app for this to work.

This is an intentional limitation by Apple, imagine the consequences if developers could bring apps from the background to the foreground and open other apps.

Dávid Pásztor
  • 51,403
  • 9
  • 85
  • 116
  • How can this description of `updateApplicationContext` help in my particular question? I want to open App Store immediately and `updateApplicationContext` is not suited for this. – kelin Aug 14 '17 at 11:53
  • Before the edit it wasn't clear at all what the actual problem is. However, I have updated my answer based on your edit. – Dávid Pásztor Aug 14 '17 at 12:28