【问题标题】:Launching iPhone app from paired apple watch从配对的 Apple Watch 启动 iPhone 应用程序
【发布时间】:2015-09-01 18:20:22
【问题描述】:

我正在尝试实施一种解决方法,以从其 Apple Watch 应用程序打开我的 iPhone 应用程序。

这是我通过通知执行此操作的用例:

Watch displays an available deal with a CTA button to see details on Phone

--------------------------
New rates options published! 

check details on phone

<Button>
---------------------------

当用户选择手表上的按钮时,用户会收到本地通知 在配对手机上“查看您的新房价选项”

选择本地通知后,应用会启动并显示详细信息。

我的做法是:

**On watch:**

call *openParentApplication:reply:*    ...this will open the iOS app in the background

**On app:** 

In *application:handleWatchKitExtensionRequest:reply:* 
...which is called on the iOS app when opened in background, trigger a local notification 


**User:**

User picks the local notification to bring app to the foreground

这行得通吗?如果是这样,如何从后台运行的应用程序触发即时本地通知?

最后一个问题:有没有一种(合法的)方法可以做到这一点而不需要本地通知(不会被应用商店拒绝的通知)?

【问题讨论】:

    标签: ios notifications uilocalnotification watchkit apple-watch


    【解决方案1】:

    批准的做法是使用Handoff 而不是本地通知。通过 Handoff,您可以使用 WKInterfaceControllerupdateUserActivity:userInfo:webpageURL: 方法指定手表上发生的当前活动。然后,当用户查看 iPhone 的锁定屏幕时,他们会在左下角看到应用程序的图标。从那里向上滑动将启动应用程序,并且 Handoff 活动将在应用程序启动时传递到应用程序中,以便您可以根据需要进行深度链接。

    为此目的使用本地通知可能会奏效,但会有一些缺点。首先,它是严厉的;切换在其方法中更加被动。其次,为了安排本地通知,用户必须同意接收它们;从用户的角度来看,这是出乎意料的行为。

    另外,请记住,在 watchOS 2 中,openParentApplication:reply: 方法不可用……真正的通信 API 已取而代之。查看WatchOS 2 Transition Guide 了解更多信息,并查看 WatchConnectivity 框架。

    【讨论】:

    • 当然——应该考虑过交接!谢谢指点!会试试这个。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多