iosremote-notifications

Why it works when I use UIApplicationLaunchOptionsLocalNotificationKey to receive remote notifications?


When I tried to get remote notifications, I made a mistake that using UIApplicationLaunchOptionsLocalNotificationKey as the LaunchingOptions dictionary's key to get information. But it all works well on my real iPhone(10.2).

enter image description here

I can tap the remote notification to launch my app. Why is that?


Solution

  • In the link I shared there is a part:

    When to Use Local and Remote Notifications

    Because apps on iOS, tvOS, and watchOS are not always running, local notifications provide a way to alert the user when your app has new information to present. For example, an app that pulls data from a server in the background can schedule a local notification when some interesting piece of information is received. Local notifications are also well suited for apps such as calendar and to-do list apps that need to alert the user at a specific time or when a specific geographic location is reached.

    Remote notifications are appropriate when some or all of the app’s data is managed by your company’s servers. With remote notifications, you decide when you want to push a notification to the user’s device. For example, a messaging app would use remote notifications to let users know when new messages arrive. Because they are sent from your server, you can send remote notifications at any time, including when the app is not running on the user’s device.