Search code examples
iosswiftimessageimessage-extension

Is it possible to check in my iOS App whether the iMessage Extension for it has been installed?


I would like to check, in my iOS app, whether the iMessage Extension for this same app has been installed, whenever my app starts up. Then every N days I would like to remind the user to install the iMessage app in a custom popup alert.

I know that I can link to the iMessage app store directly like this: https://itunes.apple.com/us/app/classic-mac/id1127542169?app=messages

But how can i detect whether the iMessage extension has already been installed or not on a user's device? I only want to show the popup reminder if it is NOT currently installed.

I haven't been able to find any specific URL scheme for iMessage extensions that I could query against.


Solution

  • You can do this with AppGroups!

    From the App Extension Programming Guide

    You can, however, enable data sharing. For example, you might want to allow your app extension and its containing app to share a single large set of data, such as prerendered assets.

    To enable data sharing, use Xcode or the Developer portal to enable app groups for the containing app and its contained app extensions. Next, register the app group in the portal and specify the app group to use in the containing app. To learn about working with app groups, see Adding an App to an App Group.

    After you enable app groups, an app extension and its containing app can both use the NSUserDefaults API to share access to user preferences. To enable this sharing, use the initWithSuiteName: method to instantiate a new NSUserDefaults object, passing in the identifier of the shared group.

    You could just flip a boolean in the shared NSUserDefaults to track install state for the extension.