Skip to content

gcm.message_id in notification must be present even if external provider is used for iOS #129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bozzanova-ab opened this issue Sep 9, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@bozzanova-ab
Copy link

Encountered this issue when updating an app to the latest version of @nativescript/firebase-messaging-core (app had previously used @nativescript/firebase).

Sending the following notification to the app works on Android, but on iOS nothing happens when you tap it, the addOnMessage nor the addOnNotificationTap callbacks are triggered.

{
	"aps": {
		"alert": {
			"title": "My title",
			"body": "The body of the notification"
		},
		"badge": 9,
		"sound": "sound"
	},
	"id": 123,
	"url": "wp/v2/post"
}

However, adding "gcm.message_id" to it will trigger the callbacks:

{
	"aps": {
		"alert": {
			"title": "My title",
			"body": "The body of the notification"
		},
		"badge": 9,
		"sound": "sound"
	},
	"id": 123,
	"url": "wp/v2/post",
	"gcm.message_id": "123"
}

In the userNotificationCenter(_:didReceive:withCompletionHandler:) function the registered callback is only fired if gcm.message_id is not null:

if (remoteNotification["gcm.message_id"] != nil) {
var message = parseNotification(response.notification)
message["foreground"] = UIApplication.shared.applicationState == UIApplication.State.active
NSCFirebaseMessagingCore.onNotificationTapCallback?(message)
}

You shouldn't be required to add "gcm.message_id" to your notification call if you aren't using Firebase for iOS.

@triniwiz triniwiz added the bug Something isn't working label Sep 21, 2022
@bozzanova-ab
Copy link
Author

There is still an issue with this. While callback is fired, the callbacks argument does not match RemoteMessage, as parseNotification is not used.

if (remoteNotification["gcm.message_id"] != nil) {
var message = parseNotification(response.notification)
message["foreground"] = UIApplication.shared.applicationState == UIApplication.State.active
NSCFirebaseMessagingCore.onNotificationTapCallback?(message)
}else {
if((response.notification.request.trigger as? UNPushNotificationTrigger) != nil){
var message = remoteNotification
message["foreground"] = UIApplication.shared.applicationState == UIApplication.State.active
NSCFirebaseMessagingCore.onNotificationTapCallback?(message)
}
}

This means that custom properties to the notification appears at the top level instead of under the data property of the callbacks argument.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants