gorush icon indicating copy to clipboard operation
gorush copied to clipboard

Cant pass ios spectific fields through FCM

Open Noomegipy opened this issue 5 years ago • 4 comments

Hi! I have a problem. I try to pass "alert" field through FCM. As far as I understand FCM works both for ios and android but for go rush its like "android mode". And i need to pass ios specific field alert through him like this

{
  "notifications": [
    {
      "tokens": ["123"],
      "platform": 2,
      "message": "Ground control to major Tom",
				"alert": {
					"title" : "Game Request",
					"body" : "Bob wants to play poker",
					"action-loc-key" : "PLAY"
      }
		}
  ]
}

Is it possible? I pass platform = 2 because it FCM

Noomegipy avatar Jun 10 '20 07:06 Noomegipy

Also i try to pass those keys inside "notification" key, but keys like "body_loc_key"(its alternative of "action_loc_key" in APNS not working

Noomegipy avatar Jun 10 '20 08:06 Noomegipy

In general, I am trying to display a button for ios through FCM:)

Noomegipy avatar Jun 10 '20 08:06 Noomegipy

@Noomegipy Please check the following document since you want to use FCM https://firebase.google.com/docs/cloud-messaging/concept-options

Maybe you can try the following code to test:

{
    "notifications": [{
        "tokens": ["123"],
        "platform": 2,
        "message": "Ground control to major Tom",
        "apns": {
            "payload": {
                "aps": {
                    "alert": {
                        "title" : "Game Request",
                        "body" : "Bob wants to play poker",
                        "action-loc-key" : "PLAY"
                    }
                }
            }
      }
    }]
}

please check function GetAndroidNotification in source code goursh/notification_fcm.go

dukepan2005 avatar Jun 10 '20 15:06 dukepan2005

I have same issue with @Noomegipy . I want to send badge number to iOS device by FCM, but it 's not working.

duongson1961996 avatar Nov 29 '20 08:11 duongson1961996