androidpush-notificationandroid-manifesturbanairship.comandroid-push-notification

Upgrading UrbanAirship Library from 8.3.2 to 9.0.0


Push notifications are not working correctly for me because I am using an old Urban Airship (now re-branded simply as Airship) SDK. I am using Version 8.3 and I need to upgrade to Version 9.0.0. I am reading https://github.com/urbanairship/android-library/blob/master/documentation/migration/migration-guide.md for instructions about how to upgrade. I found this section that is relevant to my case:

UrbanAirship Library 8.x to 9.0.0

GCM

All of the GCM classes have been moved into the package com.urbanairship.push.gcm. If you have manually added the GcmPushReceiver or UAInstanceIDListenerService in your manifest, please update the entries.

I found two AndroidManifest.xml files in my source code:

  1. C:\Users[path]\app\src\main\AndroidManifest.xml

    <!-- Optional: Receives push and registration events from the Urban Airship SDK. -->

    <intent-filter>
        <action android:name="com.urbanairship.push.CHANNEL_UPDATED"/>
        <action android:name="com.urbanairship.push.OPENED"/>
        <action android:name="com.urbanairship.push.DISMISSED"/>
        <action android:name="com.urbanairship.push.RECEIVED"/>
    
        <category android:name="${applicationId}"/>
    </intent-filter>
    

  2. C:\Users[path]\app\build\intermediates\exploded-aar\com.urbanairship.android\urbanairship-sdk\8.3.2\AndroidManifest.xml

``

    <service
        android:name="com.urbanairship.push.UAInstanceIDListenerService"
        android:exported="false" >
        <intent-filter android:priority="-999" >
            <action android:name="com.google.android.gms.iid.InstanceID" />
        </intent-filter>
    </service>

    <receiver
        android:name="com.urbanairship.push.GcmPushReceiver"
        android:permission="com.google.android.c2dm.permission.SEND" >
        <intent-filter android:priority="-999" >
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />

            <category android:name="${applicationId}" />
        </intent-filter>
    </receiver>

Question 1. When the instructions ask to update entries in your manifest, does it refer to the first or second AndroidManifest.xml file that I listed above? I assume it could only refer to C:\Users[path]\app\src\main\AndroidManifest.xml because C:\Users\[path]\app\build\intermediates\exploded-aar\com.urbanairship.android\urbanairship-sdk\8.3.2\AndroidManifest.xml would be automatically generated when compiling the app.

Question 2. When the instructions say that in your manifest, please update the entries, does it mean to remove the manually added lines because the package com.urbanairship.push.gcm already includes GcmPushReceiver and UAInstanceIDListenerService and it would automatically be taking care of it?

Thank you.

UPDATE 1: Looking at the Android.Manifest.xml file at https://github.com/urbanairship/android-library/blob/master/urbanairship-gcm/src/main/AndroidManifest.xml, mine should look like that once I upgrade to Version 9.7.1, correct? Then I should include in my project the files/classes listed at https://github.com/urbanairship/android-library/tree/master/urbanairship-gcm/src/main/java/com/urbanairship/push/gcm. Correct?


Solution

  • Now I am using this in my build.gradle (Module: app):

    // Urban Airship SDK
    //compile 'com.urbanairship.android:urbanairship-sdk:8.3.+'
    implementation 'com.urbanairship.android:urbanairship-fcm:9.7.1'
    

    I also had to do the following though, to get rid of some errors I initially saw when using implementation 'com.urbanairship.android:urbanairship-fcm:9.7.1':

    1. Installed `Android SDK Platform 28 (platforms;android-28)
    2. Replaced compileSdkVersion 23 with compileSdkVersion 28 in `build.gradle (Module: app)

    enter image description here enter image description here

    I also used File > Invalidate Caches / Restart... just in case, to make sure everything was refreshed after I modified the build.gradle (Module: app) file.