freshplanet / ANE-Push-Notification

Air Native Extension (iOS and Android) for Push Notification
Apache License 2.0
205 stars 104 forks source link

Can't get any response from GCM on Android 5 and 5.1 (Lollipop) #77

Closed maggiemaria closed 7 years ago

maggiemaria commented 9 years ago

Push notifications work perfectly on all devices except those having Android 5.0 or 5.1 OS. The application doesn't receive any response from GCM. Neither PERMISSION_GIVEN_WITH_TOKEN_EVENT nor PERMISSION_REFUSED_EVENT are never raised. Could you please help me? Thanks in advance!

This is my code:

PushNotification.getInstance().registerForPushNotification(GOOGLE_PROJECT_ID);                   PushNotification.getInstance().addEventListener(PushNotificationEvent.PERMISSION_REFUSED_EVENT, onPushNotificationTokenFailed); 
    function onPushNotificationToken(event:PushNotificationEvent):void { 
    trace("My push token is: " + event.token); 
}
    function onPushNotificationTokenFailed(event:PushNotificationEvent):void
        {
            trace(event.errorCode);
            trace(event.errorMessage);
            trace();
        }
<permission android:name="MY_APP_ID.permission.C2D_MESSAGE"      android:protectionLevel="signature" /> 
<uses-permission android:name="MY_APP_ID.permission.C2D_MESSAGE" /> 
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<application> 
<activity android:name="com.freshplanet.nativeExtensions.NotificationActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" /> 
<receiver android:name="com.freshplanet.nativeExtensions.C2DMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND"> 
<intent-filter> 
    <action android:name="com.google.android.c2dm.intent.RECEIVE" /> 
        <category android:name="MY_APP_ID" /> 
</intent-filter> 
<intent-filter> 
    <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> 
        <category android:name="MY_APP_ID" /> 
</intent-filter> 
</receiver> 
<service android:name="com.freshplanet.nativeExtensions.LocalNotificationService"/> 
<receiver android:name="com.freshplanet.nativeExtensions.LocalBroadcastReceiver" android:process=":remote">
</receiver> 
</application>
mariommoreno commented 9 years ago

Same problem here, but different Android version (4.4.4).

maggiemaria commented 9 years ago

Do you have this problem only on Android 4.4.4? PushNotification.getInstance().registerForPushNotification(GOOGLE_PROJECT_ID);
Remember that the GOOGLE_PROJECT_ID you need to send is in fact the project number in GCM. Anyway, that doesn't solve the problem on Android 5 and above

mariommoreno commented 9 years ago

With other versions (or devices) registerForPushNotification is working. Maybe in my case it's not about the version.

suitable-hero commented 9 years ago

Same here, Android 4 and 5 not working :/ There have been some changes to this branch 18 hours ago, but is the Android issue fixed?

The GCM ane described here seems to work: https://www.as3gamegears.com/air-native-extension/android-gcm/

I tested it on Android 4.x and the notifications work great, but no vibration or sound :(

Also, is it possible to wake locked Android screen with Adobe Air apps?