forked from bobeasterday/PushPlugin-deprecated
-
Notifications
You must be signed in to change notification settings - Fork 980
Open
Description
Hey!
I have an issue with the plugin. When I am in the app, and I send notification with Parse, I receive an alert with the message (this works as intended). However, when app is in the background, nothing displays on the phone. Here is how I use plugin, and how I handle notifications:
var gmcId = "xxxxxxx";
var androidConfig = {
senderID: gmcId
};
document.addEventListener("deviceready", function(){
$cordovaPush.register(androidConfig).then(function(result) {
console.log("result: " + result);
}, function(err) {
// Error
})
$rootScope.$on('$cordovaPush:notificationReceived', function(event, e) {
switch( e.event )
{
case 'registered':
if ( e.regid.length > 0 )
{
// Your GCM push server needs to know the regID before it can push to this device
// here is where you might want to send it the regID for later use.
console.log("regID = " + e.regid);
}
break;
case 'message':
// if this flag is set, this notification happened while we were in the foreground.
// you might want to play a sound to get the user's attention, throw up a dialog, etc.
if ( e.foreground )
{
// if the notification contains a soundname, play it.
navigator.notification.beep(1);
alert(e.payload.data.alert)
}
else
{ // otherwise we were launched because the user touched a notification in the notification tray.
if ( e.coldstart )
{
}
else
{
navigator.notification.beep(1);
alert(e.payload.data.alert)
}
}
break;
case 'error':
$("#app-status-ul").append('<li>ERROR -> MSG:' + e.msg + '</li>');
break;
default:
$("#app-status-ul").append('<li>EVENT -> Unknown, an event was received and we do not know what it is</li>');
break;
}
});
}, false);
Thanks!!
Btw, this is the structure of the Parse notification that I receive:
{"collapse_key":"do_not_collapse",
"event":"message",
"foreground":true,
"from":"xxxxxxxxxx",
"payload":{
"data": {"alert":"asdasdas","push_hash":"bff149a0b87f5b0e00d9dd364e9ddaa0"},"push_id":"2iFhVp2R4u","time":"2015-07-21T12:24:09.905Z"}}
Edit:
Here is my AndroidManifest
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="com.ionicframework.xxxxxx." xmlns:android="http://schemas.android.com/apk/res/android">
<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.ACCESS_WIFI_STATE" />
<application android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name" android:supportsRtl="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.Black.NoTitleBar" android:windowSoftInputMode="adjustPan">
<intent-filter android:label="@string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:exported="true" android:name="com.plugin.gcm.PushHandlerActivity" />
<receiver android:name="com.plugin.gcm.CordovaGCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.ionicframework.xxxxxx." />
</intent-filter>
</receiver>
<service android:name="com.plugin.gcm.GCMIntentService" />
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
</application>
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="22" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<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" />
<permission android:name="com.ionicframework.xxxxxx.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.ionicframework.xxxxxx.permission.C2D_MESSAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
And this is what I get from debuggin when I send push notification and app is in background:
I/GCM ( 4177): GCM message com.xxxxxx.xxxxxxxx 0:1437489184268058%b9a1ad81f9fd7ecd
V/GCMBroadcastReceiver(22357): onReceive: com.google.android.c2dm.intent.RECEIVE
V/GCMBroadcastReceiver(22357): GCM IntentService class: com.plugin.gcm.GCMIntentService
V/GCMBaseIntentService(22357): Acquiring wakelock
V/GCMBaseIntentService(22357): Intent service name: GCMIntentService-GCMIntentService-8
D/GCMIntentService(22357): onMessage - context: android.app.Application@2b12b79a
V/GCMBaseIntentService(22357): Releasing wakelock
Metadata
Metadata
Assignees
Labels
No labels