我将FIREBASE CLOUD MESSAGING服务与我的离子产品和phonegap-plugin-push cordova插件一起使用,以从PHP BACK END获取推送通知。
当我尝试获取推送通知时,php end将获得如下所示的成功结果。
样本推送数据有效载荷
{“ multicast_id”:8853634389214913500,“ success”:1,“ failure”:0,“ canonical_ids”:0,“ results”:[{“ message_id”:“ 0:1495614850271706%39688dd8f9fd7ecd”}]}
技术规格:
cordova推送通知插件版本:1.9.4
平台和版本:Ionic V1
Ionic CLI版本:2.1.13
科尔多瓦版本:科尔多瓦--6.4.0
适用于cordova的Android平台:6.0.0
Android)我测试过的设备供应商:三星,华为,小米等。
示例代码说明了以下问题
离子部分:
//推送通知if(window.cordova){if(!localStorage.getItem('device_token')){var apkId = 0; var iosId = 0; var options = {android:{senderID:MY FCM SENDER ID,icon:“ alert”,},ios:{alert:“ true”,徽章:“ true”,声音:“ true”},Windows:{}};
//localStorage.getItem('gcmRegId')
// initialize
$cordovaPushV5.initialize(options).then(function () {
// start listening for new notifications
$cordovaPushV5.onNotification();
// start listening for errors
$cordovaPushV5.onError();
// register to get registrationId
$cordovaPushV5.register().then(function (data) {
//alert("GCM"+data);
// if Android device. …Run Code Online (Sandbox Code Playgroud)php cordova ionic-framework phonegap-pushplugin firebase-cloud-messaging