Swift push notification
create project
add required POD
create apns key in apple developer portal
upload that token in to firebase project
------------
push notfication in appDelegate method execution steps
didFinishLaunchingWithOptions
didReceiveRegistrationToken -- this return the push token
didRegisterForRemoteNotificationsWithDeviceToken -- this will run when app kill and run again
send notification from firebase
app is in foreground - userNotificationCenter - willPresent
app in bg -
notification shows in notification bar
click on notification' - userNotificationCenter - didReceive
app kill and send notification (same as above)
notification shows in notification bar
click on notification' - userNotificationCenter - didReceive
-------------
{
"to": "PUSH_TOKEN_HERE",
"notification": {
"body": "You have authorized LKR 20.00 to test from your A/C *******0269 on 23-04-2018 at 11:10. TXN ID : 20857",
"title": "Payment Successful !!",
"icon": ""
},
"data": {
"notificationType": "WEB_PAYMENT",
"data": {
"instrumentReference": "W000000000000631"
}
}
}
notification - this part automatically handled by app when only app in background (both android and ios). it shows notification. we need to pass body and title
data - this part only trigger when app is in forground (in both ios & android). we can catch these values inside data object.
No comments:
Post a Comment