我正在使用phonegap push plugin
我的问题是我在实际设备中得到了onNotification
功能警告消息“结果:确定”,我也检查了。
我的config.xml
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.xxxxxxxxxxx.xxxxxxxxxxxx" version="6.2" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
<name>xxxxxxxx</name>
<description>
The #1 Mobile App to Earn Money on xxxxxx .
</description>
<author email="xxxxxx" href="http://xxxxxx.com">
xxxxxx Team
</author>
<icon src="icon.png" />
<content src="index.html" />
<access origin="*" />
<feature name="PushPlugin">
<param name="android-package" value="com.plugin.gcm.PushPlugin" />
</feature>
<feature name="NetworkStatus">
<param name="android-package" value="org.apache.cordova.networkinformation.NetworkManager" />
</feature>
<gap:plugin name="org.apache.cordova.InAppBrowser" />
<icon src="icon.png" />
<icon gap:platform="android" height="114" src="res/icon/android/icon-xxhdpi.png" width="114" />
<icon gap:platform="android" height="96" src="res/icon/android/icon-xhdpi.png" width="96" />
<icon gap:platform="android" height="72" src="res/icon/android/icon-hdpi.png" width="72" />
<icon gap:platform="android" height="48" src="res/icon/android/icon-mdpi.png" width="48" />
<icon gap:platform="android" height="36" src="res/icon/android/icon-ldpi.png" width="36" />
<icon gap:platform="ios" src="res/icon/ios/icon.png" />
<engine name="android" spec="^4.0.0" />
</widget>
还在manifest.xml文件中添加了Internet权限。
我的gcm代码:
window.plugins.pushNotification.register(successHandler, errorHandler, {
ecb : 'onNotificationGCM',
senderID : 'xxxxxxxxxxxxxx'// Google Project ID.
});
// Method to handle device registration for Android.
var onNotificationGCM = function(e) {
alert(e.event);
if('registered' === e.event) {
// Successfully registered device.
alert(e.regid);
}
else if('error' === e.event) {
// Failed to register device.
alert(e.msg);
}
else if('message' === e.event) {
//mesage recived
alert(e.payload.message);
}
};
// result contains any message sent from the plugin call
function successHandler (result) {
alert('result = ' + result);
}
// result contains any error description text returned from the plugin call
function errorHandler (error) {
alert('error = ' + error);
}
如何从gcm获取注册ID。