How does Push on App not work?

Can I open an iOS app based on push notification content? I believe this is impossible. Is there another way? I believe we can go with widgets in iOS10, right? Please suggest a good solution?

Thank!

+5


source to share


3 answers


Whenever your payload has content-available:1

, your application will be called on backgroundstate as soon as it arrives and called application(_:didReceiveRemoteNotification:fetchCompletionHandler:)

. It will only be called if the user has manually killed the application. (This does not start your application. It does require your application to start, though)



After you said your app was terminated (by the user) but the user clicks on the notification, your app is launched from the didFinishLaunching ... delegate method.

+2


source


Whenever the user clicks on the push notification, the app is launched from a non-working state to managing the state on in the 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")
}

      

+1


source


Yes, we cannot open ios apps on push notifications, but we can run the push notification app. It is called VOIP notification. You may have more information regarding this from below link https://github.com/hasyapanchasara/PushKit_SilentPushNotification

0


source







All Articles