Hello everyone, I’m trying to handle notifications in Swift 5 when my app is completely closed. All the methods I tried, I can’t receive the data of the notification when the app opens. Does anyone know how to fix this?
Hi @blakerocks, are you using local notifications or remote?
What is your xcode version? Do you have just the AppDelegate in your project or also a SceneDelegate?
There is a function that handles when notifications are received, so when you tap on a notification and it will open/start your application. The data is passed to you in a structure with the UserData.
I solved the problem by adding the code below to the project.
FIRInstanceIDAPNSTokenType.Sandbox will be used when you install the app though TestFlight,
and FIRInstanceIDAPNSTokenType.Prod when your app goes live on the App Store.
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData)
@lewis-h, awesome! Thank you for sharing your solution. Glad you were able to figure it out.