appleboy / gorush

A push notification server written in Go (Golang).
MIT License
7.95k stars 840 forks source link

Cant pass ios spectific fields through FCM #519

Open Noomegipy opened 4 years ago

Noomegipy commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

dukepan2005 commented 4 years ago

@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

duongson1961996 commented 3 years ago

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