Hello, I'm developing Push Notification on IOS 13 for our chat app. I want to achieve the below scenario -
When the chat app is running in background and the device receives a chat message, (1) the user can see an alert banner popping up; (2) the app can receive the push notification payload inside this block - "application(_:didReceiveRemoteNotification:fetchCompletionHandler:)",
which is in App Delegate.
From this wiki (https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623013-application), I assume these can be achieved.
Now I succeeded in (1) but failed in (2). This "didReceiveRemoteNotification" can never be invoked when the app is in background...
FYI -
- when the app is running in foreground, the "didReceiveRemoteNotification" can be called.
- Not sure if my testing method is correct...I connect my physical iPhone with the MacBook, open the program in Xcode and hit "run" button in Xcode to run this program.
3.Below please my notification template -
"{"aps":{"mutable-content":1,"sound":"default", "alert":{"title":"New Message"}},"data": "customized content"}
I'm not sure if I will need to add "content-available: 1" as well.
Thanks for your answer!