Skip to content

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

Closed
@bozzanova-ab

Description

@bozzanova-ab

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions