Pushnotification Server side Implementation

后端 未结 2 1312
我在风中等你
我在风中等你 2020-11-30 14:36

Recently i have integreted the FCM in my app recent version but my previous version of app was using GCM. Any ideas about whether we need to segregate the write the backgrou

相关标签:
2条回答
  • 2020-11-30 15:25

    I have working code in my project, you can try it using Firebase of google: Firebase Tutorial

                    $notification_send ="Message to be sent";
    
                    $server_key = '****************************';//Authorization Key
                    $client = new Client();
                    $client->setApiKey($server_key);
                    $client->injectGuzzleHttpClient(new \GuzzleHttp\Client());
                    $message = new Message();
                    $message->setPriority('high');
                    $message->addRecipient(new Topic('test'));
                    $message
                        ->setNotification(new Notification('Reislivsmessen', $notification_send ))
                        ->setData(['key' => 'value']);
    
                    $response = $client->send($message);
    

    You have to create topic, here it's "test".

    I hope it works for you too.

    0 讨论(0)
  • 2020-11-30 15:29

    FCM is still compatible with GCM, seeing as it is it's core. So switching to the FCM endpoint (https://fcm.googleapis.com/fcm/send) when sending your notification should still work for your app versions that have GCM. No need to write separate programs.

    0 讨论(0)
提交回复
热议问题