将 UrbanAirship 库从 8.3.2 升级到 9.0.0

Upgrading UrbanAirship Library from 8.3.2 to 9.0.0

推送通知对我来说无法正常工作,因为我使用的是旧的 Urban Airship(现在更名为 Airship)SDK。我正在使用 8.3 版,我需要升级到 9.0.0 版。我正在阅读 https://github.com/urbanairship/android-library/blob/master/documentation/migration/migration-guide.md 以获取有关如何升级的说明。我找到了与我的案例相关的部分:

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.

我在我的源代码中发现了两个 AndroidManifest.xml 文件:

  1. C:\Users[路径]\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[路径]\app\build\intermediates\exploded-aar\com.urbanairship.android\urbanairship-sdk.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>

问题 1. 当指令要求更新条目 in your manifest 时,它指的是我上面列出的第一个还是第二个 AndroidManifest.xml 文件?我假设它只能引用 C:\Users[path]\app\src\main\AndroidManifest.xml 因为 C:\Users\[path]\app\build\intermediates\exploded-aar\com.urbanairship.android\urbanairship-sdk.3.2\AndroidManifest.xml 会在编译应用程序时自动生成。

问题2.当说明里说in your manifest, please update the entries的时候,是不是意味着去掉手动添加的行,因为包com.urbanairship.push.gcm已经包含了GcmPushReceiverUAInstanceIDListenerService 它会自动处理它吗?

谢谢。

更新 1: 查看 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 中的 Android.Manifest.xml 文件。正确吗?

现在我在 build.gradle (Module: app) 中使用它:

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

我还必须执行以下操作,以消除我最初在使用 implementation 'com.urbanairship.android:urbanairship-fcm:9.7.1' 时看到的一些错误:

  1. 已安装 `Android SDK 平台 28(平台;android-28)
  2. 在`build.gradle(模块:app)中用compileSdkVersion 28替换了compileSdkVersion 23

为了以防万一,我还使用了 File > Invalidate Caches / Restart...,以确保在我修改 build.gradle (Module: app) 文件后刷新了所有内容。