How to send push notifications to multiple devices using php script using FCM?

前端 未结 5 1449
-上瘾入骨i
-上瘾入骨i 2021-01-12 05:55

I\'m new to push notifications using FCM from php to Android devices. From android side I have generated FCM reg_id & send it over php script & store into mysql data

5条回答
  •  孤独总比滥情好
    2021-01-12 06:45

    If you were to send notification via terminal the data part of the curl command would look like this:

    {
    "registration_ids": ["device_token_1", "device_token_2"],
    "notification": {
        "body": "Hello",
        "title": "Hello",
        "vibrate": 1,
        "sound": 1
     }
    }
    

    PHP code:

    $body = array(
            'registration_ids' => array("device_token_1", "device_token_2"),
            'notification' => array('body' => 'Hello', 'title' => 'Hello', 'vibrate' => 1, 'sound' => 1)
        );
    

提交回复
热议问题