是否可以在我的 iOS 应用程序中检查是否已安装它的 iMessage 扩展程序?
Is it possible to check in my iOS App whether the iMessage Extension for it has been installed?
我想在我的 iOS 应用程序启动时检查是否已安装该应用程序的 iMessage 扩展程序。然后每隔 N 天,我想提醒用户在自定义弹出警报中安装 iMessage 应用程序。
我知道我可以像这样直接 link 到 iMessage 应用程序商店:
https://itunes.apple.com/us/app/classic-mac/id1127542169?app=messages
但是我如何检测用户设备上是否已经安装了 iMessage 扩展?如果当前未安装,我只想显示弹出提醒。
我还没有找到任何特定的 URL 可以查询的 iMessage 扩展方案。
您可以使用 AppGroups 做到这一点!
来自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.
您可以在共享的 NSUserDefaults 中翻转一个布尔值来跟踪扩展的安装状态。
我想在我的 iOS 应用程序启动时检查是否已安装该应用程序的 iMessage 扩展程序。然后每隔 N 天,我想提醒用户在自定义弹出警报中安装 iMessage 应用程序。
我知道我可以像这样直接 link 到 iMessage 应用程序商店: https://itunes.apple.com/us/app/classic-mac/id1127542169?app=messages
但是我如何检测用户设备上是否已经安装了 iMessage 扩展?如果当前未安装,我只想显示弹出提醒。
我还没有找到任何特定的 URL 可以查询的 iMessage 扩展方案。
您可以使用 AppGroups 做到这一点!
来自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.
您可以在共享的 NSUserDefaults 中翻转一个布尔值来跟踪扩展的安装状态。