Check if user has AppleWatch connected without prompting the watch

廉价感情. 提交于 2021-02-07 20:52:21

问题


We are using Google Analytics, and want to know how many of our users are in possession of an AppleWatch. I have searched Stack for answers, and the recurring answer is to use this:

if WCSession.isSupported() { // check if the device support to handle an Apple Watch
        let session = WCSession.defaultSession()
        session.delegate = self
        session.activateSession() // activate the session

        if session.paired { // Check if the iPhone is paired with the Apple Watch
                // Do stuff
        }
    }

The problem with this is that it prompts the user to 'accept' the app on the AppleWatch. Granted, the if-statement is true wether or not the user accepts, but I don't want the user to get their hopes up, thinking the app supports AppleWatch. I simply want to know if the user has an AppleWatch, I don't want to use it. Yet. Is there a property on the iOS-device that can be accessed to show if the user has or ever had an AppleWatch connected, without prompting the user through the Watch?


回答1:


Probably you can use (Push)Notifications, since there is no need to develop a native applewatch app to receive notifications on the watch. For example i receive "whats app messages" on my watch, but it does not have any native app on the watch either.

In your watchkit extension ExtensionDelegate.m you can handle provided answers to the push message separately. Link to Apple

This would be a(nother) approach, where you have to be creative!



来源:https://stackoverflow.com/questions/33672447/check-if-user-has-applewatch-connected-without-prompting-the-watch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!