Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Notifications don't appear when the app is not running in the background #211

Closed
vikasing opened this issue Oct 7, 2015 · 19 comments
Closed
Labels

Comments

@vikasing
Copy link

vikasing commented Oct 7, 2015

Sometimes notifications don't appear when the app is not running in the background. I can see notifications are getting delivered to the device in logcat, but the app fails to launch:

10-07 23:01:00.035 840-840/? D/StatusBar.Clock: Receive ACTION_TIME_TICK
10-07 23:01:04.144 1198-25021/? I/GCM: GCM message com.example 0:1444239064801662%5866dd3001bf28ae
10-07 23:01:04.166 671-693/? W/BroadcastQueue: Reject to launch app com.example/10230 for broadcast: App Op 48
10-07 23:01:04.170 1198-1198/? W/GCM-DMM: broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE pkg=com.example (has extras) }

@vikasing vikasing changed the title Notification does not display when app is closed Notifications dont appear when the app is closed Oct 7, 2015
@vikasing vikasing changed the title Notifications dont appear when the app is closed Notifications don't appear when the app is not running in the background Oct 7, 2015
@macdonst
Copy link
Member

macdonst commented Oct 8, 2015

@vikasing the app should now get launched when a notification is received. On Android when the app is in the background the notification should show up in the notification shade. Are you seeing the message in the notification shade?

@vikasing
Copy link
Author

vikasing commented Oct 9, 2015

When I stop the app by swiping left I don't get a notification, although notification is received by the device, (see above logcat entries). This has something to do with the intent flag 'FLAG_INCLUDE_STOPPED_PACKAGES', link to the discussion https://groups.google.com/forum/#!topic/android-gcm/MqVlA3Sj26c

I have added this flag inside the onReceive method of GCMBroadcastReceiver.java inside gcm.jar, testing it right now.
On a different note, gcm.jar is deprecated, is there any plan to move to the Google Play Services anytime soon?

@macdonst
Copy link
Member

@vikasing Yes, please let me know how your testing goes. I'm not sure if adding that flag will help, what I think needs to happen is for the service to restart itself if killed.

Yup, if you look at branch issue188 you'll see I've already done that and it will be part of the 1.4.0 release.

@vikasing
Copy link
Author

The flag seems to help, I'm getting the notifications consistently, even
when the app is not there in the background.

Good to hear about play services integration.
On Oct 11, 2015 4:50 AM, "Simon MacDonald" [email protected] wrote:

@vikasing https://github.com/vikasing Yes, please let me know how your
testing goes. I'm not sure if adding that flag will help, what I think
needs to happen is for the service to restart itself if killed.

Yup, if you look at branch issue188 you'll see I've already done that and
it will be part of the 1.4.0 release.


Reply to this email directly or view it on GitHub
#211 (comment)
.

@macdonst
Copy link
Member

@vikasing you wanna do a PR to include that flag? I love to get contributions from others.

vikasing added a commit to vikasing/phonegap-plugin-push that referenced this issue Oct 13, 2015
@vikasing
Copy link
Author

Created a PR, but I'm not sure whether this can be merged without removing gcm.jar dependency from the plugin because now gcm.jar files are present in src directory.

@macdonst
Copy link
Member

@vikasing yeah, that PR can't be merged as gcm.jar was removed from the pluing.

@ne0c0de
Copy link

ne0c0de commented Feb 24, 2016

Hi

I have the same problem on my application. Push notification is arrive if the application is open in foreground or background but if i force kill the app the notification didn't appear even in notifications.

When i checked the logcat i saw this message:

I/GCM ( 6639): GCM message com.mobile.adMingle 0:1456297445266991%b1acb7f0f9fd7ecd
W/GCM-DMM ( 6639): broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE pkg=com.mobile.adMingle (has extras) }

I already check @vikasing 's codes on my plugin resource but i couldn't find it on the latest version of my downloaded plugin (1.5.3 version)

Can you please assist me what should i do?

@Nuajan
Copy link

Nuajan commented May 10, 2016

+1 Having same issue here. Why is this issue closed? Avoiding that flag proposal, are there any choices or updates on this?
My config:
cordova 6.1.1 platform android 5.1.1
plugin version 1.6.3

@zhakhalov
Copy link

+1 I don't receive any notifications to my android but ios works fine

Payload:

{
  "to": "/topics/user-5***2.android.r***s",
  "data": {
    "title": "Title",
    "message": "msg"
  }
}

Some logcats

V/PushPlugin(17747): execute: action=init
V/PushPlugin(17747): execute: data=[{"android":{"senderID":"9***8","topics":["user-5***2.android.r***s","user-5***2.android.a***s"]},"ios":{"alert":"true","badge":true,"sound":"false","senderID":"9***8","gcmSandbox":true,"topics":["user-5***2.android.r***s","user-5***2.android.a***s"]}}]
V/PushPlugin(17747): execute: jo={"senderID":"9***8","topics":["user-5***2.android.r***s","user-5***2.android.a***s"]}
V/PushPlugin(***): execute: senderID=9***8
V/PushPlugin(***): onRegistered: {"registrationId":"cq_pZfMiN...UafnT"}
D/PushPlugin(***): Subscribing to topic: user-5***2.android.r***s
D/PushPlugin(***): Subscribing to topic: user-5***2.android.a***s
D/PushPlugin(***): no icon option
D/PushPlugin(***): no iconColor option

...

W/GCM-DMM ( ***): broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE pkg=c***.***.***s (has extras) }
W/GCM-DMM ( ***): Unregister application c***.***.***s for user 0


Android: 4.4.2, 5.0.1, 6.0.0
Tested Plugin Versions: 1.7.4...1.8.1
Cordova Ver: 6.2.0

@fer-ri
Copy link

fer-ri commented Jan 4, 2017

any solution for this? my android 6.0.1

Thanks

@achavhan
Copy link

achavhan commented Mar 9, 2017

I am receiving same issue for FCM
03-09 22:30:49.481 912-927/? W/BroadcastQueue: don't launch com.app/10804 for broadcast Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x10 pkg=com.app (has extras) }
03-09 22:30:49.484 30027-30027/? W/GCM-DMM: broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE pkg=com.app (has extras) }

@DimaM-BeStreet
Copy link

DimaM-BeStreet commented May 29, 2017

Anyone got this figured?? brain-dead from not finding a solution 0_0

EDIT:
GOT IT!! well... sort of..
turns out i was testing on a Huawei phone, the OS has a white list for apps, they call it 'protected apps', they deny all apps that are not in that white list when swiped off recent tray.
YUCK :(

link:
https://www.androidheadlines.com/2016/01/how-to-fix-missing-notifications-on-huawei-phones.html

what to do about it? well.... nothing i can figure :(

@PaoloApplingua
Copy link

HI!

I'm having the same issue:
intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE

However, on my add it works, but on my two mobile devices (one Huawei and a Cubox) it doesn't't work. How did you solve it?

Thanks in advance!

@rjgpereira
Copy link

I have the exact same issue.. The notification does not show up in the notification shade, but I do get to see the notification arriving in logcat:

I/GCM     ( 1938): GCM message uk.co.boomeranged.hermes 0:1500028230524285%b51fbe7df9fd7ecd
W/GCM-DMM ( 1938): broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE pkg=uk.co.boomeranged.hermes (has extras) }

I'm testing on a Galaxy SII and a Nexus7, with the same result. Notifications work fine when the app is in background and foreground, just not when the app was force closed.

I'm not sure if the problem comes from my payload structure:

'data' => array (
    "message" => "message",
    "title" => "title",
    "content-available" => 1,
    "force-start"=> 1
)

or something to do with my Manifest File:

<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="10012" android:versionName="1.1" package="uk.co.boomeranged.hermes" 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" />
    <application android:hardwareAccelerated="true" android:icon="@mipmap/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:screenOrientation="portrait" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
            <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:name="com.sarriaroman.PhotoViewer.PhotoActivity" android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen" />
        <provider android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true" android:name="android.support.v4.content.FileProvider">
            <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/provider_paths" />
        </provider>
        <activity android:exported="true" android:name="com.adobe.phonegap.push.PushHandlerActivity" android:permission="${applicationId}.permission.PushHandlerActivity" />
        <receiver android:name="com.adobe.phonegap.push.BackgroundActionButtonHandler" />
        <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="${applicationId}" />
            </intent-filter>
        </receiver>
        <service android:exported="false" android:name="com.adobe.phonegap.push.GCMIntentService">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            </intent-filter>
        </service>
        <service android:exported="false" android:name="com.adobe.phonegap.push.PushInstanceIDListenerService">
            <intent-filter>
                <action android:name="com.google.android.gms.iid.InstanceID" />
            </intent-filter>
        </service>
        <service android:exported="false" android:name="com.adobe.phonegap.push.RegistrationIntentService" />
    </application>
    <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="25" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <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" />
    <uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />
    <uses-permission android:name="${applicationId}.permission.PushHandlerActivity" />
    <permission android:name="${applicationId}.permission.C2D_MESSAGE" android:protectionLevel="signature" />
    <permission android:name="${applicationId}.permission.PushHandlerActivity" android:protectionLevel="signature" />
</manifest>

I'm really stuck on this one... would really appreciate some help!

Thanks in advance

@macdonst
Copy link
Member

@rjgpereira that is #158 in a nutshell

@rjgpereira
Copy link

@PaoloApplingua I'm experiencing this behaviour on Galaxy S2, Nexus 7 and also on a Wiko. So, I don't think that's the problem here.

@macdonst I just don't get that thread. Most of the people are reporting problems with the notification event not being triggered, but they seem to be having the notification displayed in the notification area, which is not my case.
There is one person reporting the exact same issue with the "result=CANCELLED forIntent" but it says he's problem was due to using "notification" instead of "data" in the payload, but that's not my case. Is my payload example correct??

@lock
Copy link

lock bot commented Jun 3, 2018

This thread has been automatically locked.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

10 participants