Using Android GCM Push Notifications with Magic xpa 3.2a and Above (Magic xpa 3.x)
This technical note explains how to use push notifications based on GCM (the mechanism used until Magic xpa 3.2).
Note that GCM is deprecated by Android and it is better to use Firebase as explained in the Sending and Receiving Push Notifications topic. However, if you still want to use GCM, make the following changes:
-
In the RIAModules\Android\Source folder:
-
Open the build.gradle file and remove line 9: classpath 'com.google.gms:google-services:3.0.0'
-
Open the build.ps1 file and remove lines 64-65:
renamePackageNameInFile ($file)
$file = Get-Item '.\app\google-services.json'
-
In the RIAModules\Android\Source\app folder:
-
Open the build.gradle file and remove line 57: compile 'com.google.firebase:firebase-messaging:9.6.0'
-
Also remove line 61: apply plugin: 'com.google.gms.google-services'
-
Delete the google-services.json file.
-
In the RIAModules\Android\Source\app\libs folder, add the following files (take them from your 3.1 package):
-
gcm.jar
-
google-play-services.jar
-
In the RIAModules\Android\Source\app\src\main\java\com\magicsoftware\magicdev folder:
-
Delete the following files: MyFireBase*.* (4 files)
-
Add the following files (take them from 3.2):
-
Replace the following files with the ones from 3.2:
-
In the RIAModules\Android\Source\app\src\main\AndroidManifest.xml folder:
-
Add the following lines in line 18:
<!-- The following permissions are required for push notifications -->
<permission android:name="com.magicsoftware.magicdev.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.magicsoftware.magicdev.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<!--[START firebase_service] -->
<service
android:name=".MyFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
<receiver
android:name=".MyFirebaseNotificationDismissReceiver"
android:exported="false" >
</receiver>
<receiver
android:name=".MyFirebaseNotificationClickReceiver"
android:exported="false" >
</receiver>
<!--[END firebase_service] -->
<!--[START firebase_iid_service] -->
<service
android:name=".MyFirebaseInstanceIDService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
<!--[END firebase_iid_service] -->
<!--The following receiver and service are required for the push notification -->
<receiver android:name=".GCMBroadcastReceiver" 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.magicsoftware.magicdev" />
</intent-filter>
</receiver>