我沒有收到我的科爾多瓦Android應用程序推送通知。使用相同的代碼,我可以在我的iOS應用程序中接收推送通知。 早些時候,我使用pushwoosh插件從PhoneGap的版本(PGB):推送通知不在科爾多瓦接收Android應用程序
< gap:plugin name="com.pushwoosh.plugins.pushwoosh" version="3.4.2" />
推送通知,收到了既適用於iOS和Android沒有任何錯誤。
我最近改變了插件,並添加一個新問題:
< gap:plugin name="pushwoosh-cordova-plugin" version="6.4.0" source="npm" />
設備獲取pushwoosh註冊並獲得設備令牌。
GCM(php-backend)用於發送Android的推送通知。
我正在從GCM成功響應了對發送推送通知:
{"multicast_id":86307627949689xxxxx,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1480488792901983%a4d1b626f9xxxxxx"}]}
但推送通知不是由Android應用程序在任何情況下,應用程序是否正在運行的背景或前景或關閉接收。
仍從Pushwoosh面板發送當兩個應用程序的iOS和Android版本正在接收推送通知
參考文獻:http://docs.pushwoosh.com/docs/cordova-phonegap
我的代碼:
document.addEventListener("deviceready", DeviceReady, false);
function DeviceReady()
{
window.pushwoosh = cordova.require("pushwoosh-cordova-plugin.PushNotification");
// should be called before pushwoosh.onDeviceReady
document.addEventListener('push-notification', function(event) {
navigator.notification.alert(JSON.stringify(event.notification));
//get the notification payload
if (device.platform == 'android' || device.platform == 'Android') {
navigator.notification.alert(event.notification.message);
}else{
navigator.notification.alert(event.notification.aps.alert);
}
if (device.platform == 'iOS') {
pushwoosh.setApplicationIconBadgeNumber(0);
}
});
// Initialize Pushwoosh. This will trigger all pending push notifications on start.
// projectid : GOOGLE_PROJECT_NUMBER
pushwoosh.onDeviceReady({
appid: "3FXXX-3CXXX",
projectid: "4631220XXXXX"
});
pushwoosh.registerDevice(
function(status) {
var pushToken = status.pushToken;
document.getElementById('hiddentoken').value = pushToken;
},function(status) {
//~ alert("Error Status" + status);
});
//reset badges on app start
pushwoosh.setApplicationIconBadgeNumber(0);
}
清單:
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<manifest xmlns:amazon="http://schemas.amazon.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" android:windowSoftInputMode="adjustPan" package="com.XXXXX.XXXXX" platformBuildVersionCode="22" platformBuildVersionName="5.1.1-1819727">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<permission android:name="com.XXXXX.XXXXX.permission.C2D_MESSAGE" android:protectionLevel="signature"/>
<uses-permission android:name="com.XXXXX.XXXXX.permission.C2D_MESSAGE"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<uses-permission android:name="com.sec.android.provider.badge.permission.READ"/>
<uses-permission android:name="com.sec.android.provider.badge.permission.WRITE"/>
<uses-permission android:name="com.htc.launcher.permission.READ_SETTINGS"/>
<uses-permission android:name="com.htc.launcher.permission.UPDATE_SHORTCUT"/>
<uses-permission android:name="com.sonyericsson.home.permission.BROADCAST_BADGE"/>
<uses-permission android:name="com.sonymobile.home.permission.PROVIDER_INSERT_BADGE"/>
<uses-permission android:name="com.anddoes.launcher.permission.UPDATE_COUNT"/>
<uses-permission android:name="com.majeur.launcher.permission.UPDATE_BADGE"/>
<uses-permission android:name="com.huawei.android.launcher.permission.CHANGE_BADGE"/>
<uses-permission android:name="com.huawei.android.launcher.permission.READ_SETTINGS"/>
<uses-permission android:name="com.huawei.android.launcher.permission.WRITE_SETTINGS"/>
<uses-permission android:name="android.permission.READ_APP_BADGE"/>
<uses-permission android:name="com.oppo.launcher.permission.READ_SETTINGS"/>
<uses-permission android:name="com.oppo.launcher.permission.WRITE_SETTINGS"/>
<permission android:name="com.XXXXX.XXXXX.permission.RECEIVE_ADM_MESSAGE" android:protectionLevel="signature"/>
<uses-permission android:name="com.XXXXX.XXXXX.permission.RECEIVE_ADM_MESSAGE"/>
<uses-permission android:name="com.amazon.device.messaging.permission.RECEIVE"/>
<application android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:configChanges="locale|keyboard|keyboardHidden|orientation|screenSize" android:label="@string/app_name" android:name="com.XXXXX.XXXXX.Apppp" android:screenOrientation="portrait" android:windowSoftInputMode="adjustUnspecified|stateUnspecified">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/>
<meta-data android:name="PW_LOG_LEVEL" android:value="DEBUG"/>
<meta-data android:name="PW_NO_BROADCAST_PUSH" android:value="false"/>
<receiver android:exported="true" android:name="com.google.android.gms.gcm.GcmReceiver" android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
<category android:name="com.XXXXX.XXXXX"/>
</intent-filter>
</receiver>
<activity android:exported="false" android:name="com.google.android.gms.common.api.GoogleApiActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar"/>
<receiver android:name="com.pushwoosh.MessageAlertReceiver" android:permission="com.amazon.device.messaging.permission.SEND">
<intent-filter>
<action android:name="com.amazon.device.messaging.intent.REGISTRATION"/>
<action android:name="com.amazon.device.messaging.intent.RECEIVE"/>
<category android:name="com.XXXXX.XXXXX"/>
</intent-filter>
</receiver>
<service android:name="com.pushwoosh.PushAmazonIntentService"/>
<amazon:enable-feature android:name="com.amazon.device.messaging" android:required="false"/>
<activity android:name="com.pushwoosh.richpages.RichPageActivity"/>
<activity android:name="com.pushwoosh.MessageActivity"/>
<activity android:name="com.pushwoosh.PushHandlerActivity"/>
<activity android:name="com.pushwoosh.inapp.WebActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar"/>
<service android:name="com.pushwoosh.inapp.InAppRetrieverService"/>
<receiver android:enabled="true" android:name="com.pushwoosh.local.BootReceiver" android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</receiver>
<service android:exported="false" android:name="com.pushwoosh.GCMListenerService">
<intent-filter android:priority="-50">
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
</intent-filter>
</service>
<service android:exported="false" android:name="com.pushwoosh.GCMInstanceIDListenerService">
<intent-filter android:priority="-50">
<action android:name="com.google.android.gms.iid.InstanceID"/>
</intent-filter>
</service>
<service android:exported="false" android:name="com.pushwoosh.GCMRegistrationService"/>
<service android:name="com.pushwoosh.location.GeoLocationService"/>
<activity android:name="com.pushwoosh.internal.utils.PermissionActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar"/>
<receiver android:name="com.pushwoosh.local.AlarmReceiver"/>
<service android:enabled="true" android:exported="true" android:isolatedProcess="false" android:label="iBeacon" android:name="com.pushwoosh.thirdparty.radiusnetworks.ibeacon.service.IBeaconService"/>
<service android:enabled="true" android:name="com.pushwoosh.thirdparty.radiusnetworks.ibeacon.IBeaconIntentProcessor"/>
<service android:name="com.pushwoosh.beacon.PushBeaconService"/>
<service android:enabled="true" android:exported="false" android:name="com.pushwoosh.internal.utils.LockScreenService"/>
</application>
</manifest>
任何幫助將不勝感激。
這裏添加清單文件將是有益的,也許你只需要在pushwoosh接收器你的清單文件,這不理解你的服務器發送的有效載荷 –
@UmangChamaria我已經添加了Manifest文件。你可以檢查一下嗎? – Ajith