Phonegap 推送插件不工作 ANdroid
Phonegap Push plugin not wroking ANdroid
你好,我正在使用 phone gap 5.0 CLI,我正在为 android 5.0 开发应用程序,API 22 级 Js 技术是 jquery。
- 我正在为 android 平台构建并在我的设备上进行测试
- 我在我的电脑上使用 windows 7
软件是
- CLI、Eclipse 和 android
问题是phone间隙推送插件不工作
我面临的确切错误是:
10-07 13:01:14.282: E/Web Console(9564): Uncaught Type Error: Object function (options) {
10-07 13:01:14.282: E/Web Console(9564): this._handlers = {
10-07 13:01:14.282: E/Web Console(9564): 'registration': [],
10-07 13:01:14.282: E/Web Console(9564): 'notification': [],
10-07 13:01:14.282: E/Web Console(9564): 'error': []
10-07 13:01:14.282: E/Web Console(9564): };
10-07 13:01:14.282: E/Web Console(9564): // require options parameter
10-07 13:01:14.282: E/Web Console(9564): if (type of options === 'undefined') {
10-07 13:01:14.282: E/Web Console(9564): throw new Error('The options argument is required.');
10-07 13:01:14.282: E/Web Console(9564): }
10-07 13:01:14.282: E/Web Console(9564): // store the options to this object instance
10-07 13:01:14.282: E/Web Console(9564): this.options = options;
10-07 13:01:14.282: E/Web Console(9564): // triggered on registration and notification
10-07 13:01:14.282: E/Web Console(9564): var that = this;
10-07 13:01:14.282: E/Web Console(9564): var success = function(result) {
10-07 13:01:14.282: E/Web Console(9564): if (result && type of result.registration Id !== 'undefined') {
10-07 13:01:14.282: E/Web Console(9564): that.emit('registration', result);
10-07 13:01:14.282: E/Web Console(9564): } else if (result && type of result.callback !== 'undefined') {
10-07 13:01:14.282: E/Web Console(9564): var multifunctional = function(function Name, context /*, args */) {
10-07 13:01:14.282: E/Web Console(9564): var args = Array.prototype.slice.call(
arguments, 2);
10-07 13:01:14.282: E/Web Console(9564): var namespaces = function Name.split(".");
10-07 13:01:14.282: E/Web Console(9564): var func = namespaces.pop();
10-07 13:01:14.282: E/Web Console(9564): for (var i = 0; i < namespaces.length; i++) {
10-07 13:01:14.282: E/Web Console(9564): context = context[namespaces[i]];
10-07 13:01:14.282: E/Web Console(9564): }
10-07 13:01:14.282: E/Web Console(9564): return context[func].apply(context, args);
10-07 13:01:14.282: E/Web Console(9564): }
10-07 13:01:14.282: E/Web Console(9564):
10-07 13:01:14.282: E/Web Console(9564): executeFunctionByName(result.callback, window, result);
10-07 13:01:14.282: E/Web Console(9564): } else if (result) {
10-07 13:01:14.282: E/Web Console(9564): that.emit('notification', result);
10-07 13:01:14.282: E/Web Console(9564): }
10-07 13:01:14.282: E/Web Console(9564): };
10-07 13:01:14.282: E/Web Console(9564): // triggered on error
10-07 13:01:14.282: E/Web Console(9564): var fail = function(msg) {
10-07 13:01:14.282: E/Web Console(9564): var e = (typeof msg === 'string') ? new Error(msg) : msg;
10-07 13:01:14.282: E/Web Console(9564): that.emit('error', e);
10-07 13:01:14.282: E/Web Console(9564): };
10-07 13:01:14.282: E/Web Console(9564): // wait at least one process tick to allow event subscriptions
10-07 13:01:14.282: E/Web Console(9564): setTimeout(function() {
10-07 13:01:14.282: E/Web Console(9564): exec(success, fail, 'PushNotification', 'init', [options]);
10-07 13:01:14.282: E/Web Console(9564): }, 10);
10-07 13:01:14.282: E/Web Console(9564): } has no method 'init' at file:///android_asset/www/js/Module.js:8
10-07 13:01:14.392: D/TilesManager(9564): Starting TG #0, 0x5f73f420
10-07 13:01:14.392: D/TilesManager(9564): new EGLContext from framework: 5e306a90
10-07 13:01:14.392: D/GLWebViewState(9564): Reinit shader
10-07 13:01:14.442: D/netstack(9564): netstack: Request Priority is ON
10-07 13:01:14.462: D/chromium(9564): Unknown chromium error: -6
10-07 13:01:14.532: D/GLWebViewState(9564): Reinit transferQueue
10-07 13:01:14.542: E/Web Console(9564): Uncaught Error: Module phonegap-plugin-push.PushNotification does not exist. at file:///android_asset/www/cordova.js:1418
10-07 13:01:18.742: I/Web Console(9564): device Ready has not fired after 5 seconds. at file:///android_asset/www/cordova.js:1183
10-07 13:01:18.742: I/Web Console(9564): Channel not fired: onPluginsReady at file:///android_asset/www/cordova.js:1176
10-07 13:01:18.742: I/Web Console(9564): Channel not fired: onCordovaReady at file:///android_asset/www/cordova.js:1176
can any one please help me to solve this problem
thanks in advance to help me
谁能帮我解决这个问题
我正在使用 phone gap 5.0 CLI,我正在为 android 5.0 开发应用程序 API level 22 Js 技术是 jquery 我正在为 android 平台构建并且在我的设备上测试 我在我的 PC 上使用 windows 7 软件是 CLI、Eclipse 和 android 问题是 phone 间隙推送插件不工作。
该插件已被弃用。替代解决方案包括使用第三方解决方案
从日志 'Module phonegap-plugin-push.PushNotification does not exist' 来看,Phonegap Push Plugin 似乎没有正确安装,因此 Push Notification 对象未定义,或者您的代码中可能存在一些语法或编译错误,因为通常在 javascript 它是由于任何语法错误而发生的,低于它的代码失败。
在 github 上有一个当前有效的 Phonegap Push Plugin 可用,它在所有 Android Api 级别上都可以正常工作,包括牛轧糖。注册您的推送通知对象如下:
var push = PushNotification.init({
android: {
senderID: "XXXXXXXXXXXX",
},
ios: {
alert: "true",
badge: "true",
sound: "true",
}
});
push.on('registration', function(data) {
console.log(data.registrationId);
registerDeviceToken(data.registrationId);
});
push.on('notification', function(data) {
console.log("notification event");
alert(JSON.stringify(data));
});
push.on('error', function(e) {
console.log("push error");
alert(JSON.stringify(e));
});
function registerDeviceToken(deviceToken){
//Register the registrationId or deviceToken to your server as per the webservice type and parameters configuration set
}
确保仅在触发“DeviceReady”事件后调用上述代码。
您的 AndroidManifest.xml 应具有以下内容:
<application>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity
android:name="com.adobe.phonegap.push.PushHandlerActivity"
android:exported="true" />
<receiver android:name="com.adobe.phonegap.push.BackgroundActionButtonHandler" />
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="yourPackageName" />
</intent-filter>
</receiver>
<service
android:name="com.adobe.phonegap.push.GCMIntentService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<service
android:name="com.adobe.phonegap.push.PushInstanceIDListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID" />
</intent-filter>
</service>
<service
android:name="com.adobe.phonegap.push.RegistrationIntentService"
android:exported="false" />
</application>
<permission
android:name="${applicationId}.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
虽然上述配置会在您安装插件时自动添加到您的 AndroidManifest 中,但这仅供参考。
快乐编码:)
你好,我正在使用 phone gap 5.0 CLI,我正在为 android 5.0 开发应用程序,API 22 级 Js 技术是 jquery。
- 我正在为 android 平台构建并在我的设备上进行测试
- 我在我的电脑上使用 windows 7
软件是
- CLI、Eclipse 和 android
问题是phone间隙推送插件不工作 我面临的确切错误是:
10-07 13:01:14.282: E/Web Console(9564): Uncaught Type Error: Object function (options) {
10-07 13:01:14.282: E/Web Console(9564): this._handlers = {
10-07 13:01:14.282: E/Web Console(9564): 'registration': [],
10-07 13:01:14.282: E/Web Console(9564): 'notification': [],
10-07 13:01:14.282: E/Web Console(9564): 'error': []
10-07 13:01:14.282: E/Web Console(9564): };
10-07 13:01:14.282: E/Web Console(9564): // require options parameter
10-07 13:01:14.282: E/Web Console(9564): if (type of options === 'undefined') {
10-07 13:01:14.282: E/Web Console(9564): throw new Error('The options argument is required.');
10-07 13:01:14.282: E/Web Console(9564): }
10-07 13:01:14.282: E/Web Console(9564): // store the options to this object instance
10-07 13:01:14.282: E/Web Console(9564): this.options = options;
10-07 13:01:14.282: E/Web Console(9564): // triggered on registration and notification
10-07 13:01:14.282: E/Web Console(9564): var that = this;
10-07 13:01:14.282: E/Web Console(9564): var success = function(result) {
10-07 13:01:14.282: E/Web Console(9564): if (result && type of result.registration Id !== 'undefined') {
10-07 13:01:14.282: E/Web Console(9564): that.emit('registration', result);
10-07 13:01:14.282: E/Web Console(9564): } else if (result && type of result.callback !== 'undefined') {
10-07 13:01:14.282: E/Web Console(9564): var multifunctional = function(function Name, context /*, args */) {
10-07 13:01:14.282: E/Web Console(9564): var args = Array.prototype.slice.call(
arguments, 2);
10-07 13:01:14.282: E/Web Console(9564): var namespaces = function Name.split(".");
10-07 13:01:14.282: E/Web Console(9564): var func = namespaces.pop();
10-07 13:01:14.282: E/Web Console(9564): for (var i = 0; i < namespaces.length; i++) {
10-07 13:01:14.282: E/Web Console(9564): context = context[namespaces[i]];
10-07 13:01:14.282: E/Web Console(9564): }
10-07 13:01:14.282: E/Web Console(9564): return context[func].apply(context, args);
10-07 13:01:14.282: E/Web Console(9564): }
10-07 13:01:14.282: E/Web Console(9564):
10-07 13:01:14.282: E/Web Console(9564): executeFunctionByName(result.callback, window, result);
10-07 13:01:14.282: E/Web Console(9564): } else if (result) {
10-07 13:01:14.282: E/Web Console(9564): that.emit('notification', result);
10-07 13:01:14.282: E/Web Console(9564): }
10-07 13:01:14.282: E/Web Console(9564): };
10-07 13:01:14.282: E/Web Console(9564): // triggered on error
10-07 13:01:14.282: E/Web Console(9564): var fail = function(msg) {
10-07 13:01:14.282: E/Web Console(9564): var e = (typeof msg === 'string') ? new Error(msg) : msg;
10-07 13:01:14.282: E/Web Console(9564): that.emit('error', e);
10-07 13:01:14.282: E/Web Console(9564): };
10-07 13:01:14.282: E/Web Console(9564): // wait at least one process tick to allow event subscriptions
10-07 13:01:14.282: E/Web Console(9564): setTimeout(function() {
10-07 13:01:14.282: E/Web Console(9564): exec(success, fail, 'PushNotification', 'init', [options]);
10-07 13:01:14.282: E/Web Console(9564): }, 10);
10-07 13:01:14.282: E/Web Console(9564): } has no method 'init' at file:///android_asset/www/js/Module.js:8
10-07 13:01:14.392: D/TilesManager(9564): Starting TG #0, 0x5f73f420
10-07 13:01:14.392: D/TilesManager(9564): new EGLContext from framework: 5e306a90
10-07 13:01:14.392: D/GLWebViewState(9564): Reinit shader
10-07 13:01:14.442: D/netstack(9564): netstack: Request Priority is ON
10-07 13:01:14.462: D/chromium(9564): Unknown chromium error: -6
10-07 13:01:14.532: D/GLWebViewState(9564): Reinit transferQueue
10-07 13:01:14.542: E/Web Console(9564): Uncaught Error: Module phonegap-plugin-push.PushNotification does not exist. at file:///android_asset/www/cordova.js:1418
10-07 13:01:18.742: I/Web Console(9564): device Ready has not fired after 5 seconds. at file:///android_asset/www/cordova.js:1183
10-07 13:01:18.742: I/Web Console(9564): Channel not fired: onPluginsReady at file:///android_asset/www/cordova.js:1176
10-07 13:01:18.742: I/Web Console(9564): Channel not fired: onCordovaReady at file:///android_asset/www/cordova.js:1176
can any one please help me to solve this problem
thanks in advance to help me
谁能帮我解决这个问题 我正在使用 phone gap 5.0 CLI,我正在为 android 5.0 开发应用程序 API level 22 Js 技术是 jquery 我正在为 android 平台构建并且在我的设备上测试 我在我的 PC 上使用 windows 7 软件是 CLI、Eclipse 和 android 问题是 phone 间隙推送插件不工作。
该插件已被弃用。替代解决方案包括使用第三方解决方案
从日志 'Module phonegap-plugin-push.PushNotification does not exist' 来看,Phonegap Push Plugin 似乎没有正确安装,因此 Push Notification 对象未定义,或者您的代码中可能存在一些语法或编译错误,因为通常在 javascript 它是由于任何语法错误而发生的,低于它的代码失败。 在 github 上有一个当前有效的 Phonegap Push Plugin 可用,它在所有 Android Api 级别上都可以正常工作,包括牛轧糖。注册您的推送通知对象如下:
var push = PushNotification.init({
android: {
senderID: "XXXXXXXXXXXX",
},
ios: {
alert: "true",
badge: "true",
sound: "true",
}
});
push.on('registration', function(data) {
console.log(data.registrationId);
registerDeviceToken(data.registrationId);
});
push.on('notification', function(data) {
console.log("notification event");
alert(JSON.stringify(data));
});
push.on('error', function(e) {
console.log("push error");
alert(JSON.stringify(e));
});
function registerDeviceToken(deviceToken){
//Register the registrationId or deviceToken to your server as per the webservice type and parameters configuration set
}
确保仅在触发“DeviceReady”事件后调用上述代码。
您的 AndroidManifest.xml 应具有以下内容:
<application>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity
android:name="com.adobe.phonegap.push.PushHandlerActivity"
android:exported="true" />
<receiver android:name="com.adobe.phonegap.push.BackgroundActionButtonHandler" />
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="yourPackageName" />
</intent-filter>
</receiver>
<service
android:name="com.adobe.phonegap.push.GCMIntentService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<service
android:name="com.adobe.phonegap.push.PushInstanceIDListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID" />
</intent-filter>
</service>
<service
android:name="com.adobe.phonegap.push.RegistrationIntentService"
android:exported="false" />
</application>
<permission
android:name="${applicationId}.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
虽然上述配置会在您安装插件时自动添加到您的 AndroidManifest 中,但这仅供参考。
快乐编码:)