繁体   English   中英

如何处理Push on App未运行状态?

[英]How to handle Push on App not running state?

是否可以根据推送通知内容打开iOS应用程序? 我相信这是不可能的。 还有其他方法吗? 我相信我们可以使用iOS10中的小部件,对吧? 请建议一些好的解决方案?

谢谢!

每当您的有效负载具有content-available:1您的应用程序将在它到达后立即在后台状态中调用,并将调用application(_:didReceiveRemoteNotification:fetchCompletionHandler:) 如果用户手动杀死应用程序,则不会调用它。 (这不会启动您的应用。它需要启动您的应用)

说完,如果您的应用程序被终止(用户),但用户轻敲notitication那么你的应用程序是从didFinishLaunching ...委托方法推出了说。

每当用户点击推送通知时,应用程序将从未运行状态启动到AppDelegate中的运行状态

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

}
in this function you can check application is launch from push or application icon 

var notification: [AnyHashable: Any]? = (launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey] as? [AnyHashable: Any])
if notification != nil {
    print("app received notification from remote\(notification)")
    application(application, didReceiveRemoteNotification: notification)
}
else {
    print("app did not receive notification")
}

是的,我们无法在推送通知上打开ios应用程序,但我们可以通过推送通知唤醒应用程序。 它叫做VOIP通知。 您可以从以下链接获取更多相关信息https://github.com/hasyapanchasara/PushKit_SilentPushNotification

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM