Android device does not display warning in response to remote push notification when app is not running

I've seen many other questions saying the app is paused but won't receive notifications.

However, I am NOT forcing you to stop this application. I just press the back button. I also tried to just press the Home button. In both cases, there are no warnings.

However, if the app is running in the foreground, the PushReceived event fires and AData.Message shows the correct text. So it seems like the remote notifications are being sent to the device, it's just that the app never woke up to process them.

The app is written in Delphi XE8 and I tested it on KitKat and JellyBean, both with the same results.

I suspect the problem is with the android manifest file. Copy below. Other than that, I'm not sure where to go. As my understanding is that when a signal is pushed, it should run a small bit of code in the Firemonkey framework that displays a push message without running the full app.

I am using the application described in this tutorial to understand why it is not working in my real application. This worked as I expected in XE7.

http://docwiki.embarcadero.com/RADStudio/XE8/en/Mobile_Tutorial:_Using_Remote_Notifications_%28iOS_and_Android%29

I'm using the Interaction tab on the Kinvey dashboard to send test clicks, so I'm assuming the server side is correct. And as I said, they work with the application in the foreground.

Gary

<?xml version="1.0" encoding="utf-8"?>
<!-- BEGIN_INCLUDE(manifest) -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="net.gwsystemsdns.net.pushtest"
    android:versionCode="1"
    android:versionName="1.0.0"
    android:installLocation="preferExternal">

<!-- This is the platform API where NativeActivity was introduced. -->
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="11" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<permission android:name="net.gwsystemsdns.net.pushtest.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="net.gwsystemsdns.net.pushtest.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

<uses-feature android:glEsVersion="0x00020000" android:required="True"/>
<application android:persistent="False" 
    android:restoreAnyVersion="False" 
    android:label="PushTest" 
    android:debuggable="True" 
    android:largeHeap="False"
    android:icon="@drawable/ic_launcher"
    android:theme="@style/AppTheme"
    android:hardwareAccelerated="true">


    <!-- Our activity is a subclass of the built-in NativeActivity framework class.
         This will take care of integrating with our NDK code. -->
    <activity android:name="com.embarcadero.firemonkey.FMXNativeActivity"
            android:label="PushTest"
            android:configChanges="orientation|keyboard|keyboardHidden"
            android:launchMode="singleTask">
        <!-- Tell NativeActivity the name of our .so -->
        <meta-data android:name="android.app.lib_name"
            android:value="PushTest" />
        <intent-filter>  
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter> 
    </activity>

    <receiver android:name="com.embarcadero.firemonkey.notifications.FMXNotificationAlarm" />
    <receiver android:exported="true" android:name="com.embarcadero.gcm.notifications.GCMNotification" android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="net.gwsystemsdns.net.pushtest" />
</intent-filter>
</receiver>

</application>
</manifest>
<!-- END_INCLUDE(manifest) -->

      

My Push Received event that demonstrates front end reception.

procedure TfrmMain.PushEvents1PushReceived(Sender: TObject; const AData: TPushData);
begin
  Memo1.Lines.Add('Push Received');
  Memo1.Lines.Add('Push = ' + AData.Message);
end;

      

+3


source to share


1 answer


I found the problem. This line was missing from the XE8 manifest template file:

    <%activity%>
    <service android:name="com.embarcadero.gcm.notifications.GCMIntentService" />
    <%receivers%>
</application>

      

It goes into the AndroidManifest.template.xml file like this (right after the tag <%receivers%>

:



    <%activity%>
    <service android:name="com.embarcadero.gcm.notifications.GCMIntentService" />
    <%receivers%>
    <receiver android:name="com.embarcadero.firemonkey.notifications.FMXNotificationAlarm" />
</application>

      

By Embarcadero docwiki.

+1


source







All Articles