I manage to set up everything and I can sent notification from method 1(Firebase Console) or 2(HTTP Send using Javascript and Ajax)
Now after message sent, when user click on the notification, how to know it is from method 1(Firebase Console) or 2(HTTP Send using javascript and Ajax)?
The reason is I wish to redirect user to different page on the app.
Can I use the title? Method 2 message will always have a static title, if so how do I do it, please help.
Firebase Console.
HTTP send
function post() { $.ajax({ type : 'POST', url : "https://fcm.googleapis.com/fcm/send", headers : { Authorization : 'key=' + '<%=sKey%>' }, contentType : 'application/json', dataType: 'json', data: JSON.stringify({ "to": "<%=sToWhichDevice%>", "priority": "high", "notification": { "sound": "defaultSound", "title":"<%=sTitle%>", "body":"<%=sBody%>" } }), success : function(response) { console.log(response); }, error : function(xhr, status, error) { console.log(xhr.error); } }); } window.onload = post();
Detect when user click on the notification
//=== Handle notification messages after display notification is tapped by the user. - (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response NSDictionary *userInfo = response.notification.request.content.userInfo; //==== HOW DO I DIFFERENTIATE IT IS SEND from FireBase Console or HTTP Javascript Ajax send? if (userInfo[kGCMMessageIDKey]) { NSLog(@" **5 : Notification from Firebase Console. Message ID: %@", }else{ NSLog(@" **5** : Notification from HTTP Ajax"); } completionHandler(); }