Android Urban Airship 6.0.1,无法拦截推送通知操作

Android Urban Airship 6.0.1, not able to intercept push notification actions

我正在将 BaseIntentReceiver 扩展到一个新的 class PushIntentReceiver,旨在采取与推送通知对象中的 key/value 对不同的操作。

虽然我的推送通知显示正确,但 PushIntentReceiver 从未被调用。因此点击通知似乎什么都不做。每个方法里面都有一个log标签,比如

@Override
protected void onBackgroundPushReceived(Context context, PushMessage message) {
    Log.i(TAG, "Received background push message: " + message);
}

但其中 none 出现在 LogCat 中。不管是注册方式,还是通知点击方式什么的。同样,我的断点不会在这些函数中命中。

这是为什么?我已经包含了我的 AndroidManifest 的相关部分。此应用程序中的 UrbanAirship 的先前版本是在你们首次创建 Amazon UA 时从 Android UA 中分离出 Amazon UA 的版本。所以我不知道那是 Android UA 5.0 还是 4.x ,但我通过 BroadcastReceivers 进行的推送通知拦截在那个旧版本的库中确实有效。现在一切都已重组为 UA 5.1.x+ 方式,我无法让它工作。

洞察力赞赏

这是我AndroidManifest.xml

的相关部分
<!-- REQUIRED for Urban Airship -->
    <service
        android:name="com.urbanairship.push.PushService"
        android:label="Push Notification Service" />

    <!-- Required for analytics -->
    <service
        android:name="com.urbanairship.analytics.EventService"
        android:label="Event Service" />

    <!-- Required for Actions -->
    <service android:name="com.urbanairship.actions.ActionService" />

    <!-- Required for Rich Push -->
    <service android:name="com.urbanairship.richpush.RichPushUpdateService" />

    <!-- OPTIONAL for Urban Airship Location (for segments support) -->
    <service
        android:name="com.urbanairship.location.LocationService"
        android:label="Segments Service" />

    <!-- This is required for persisting preferences related to push and location -->
    <!-- MODIFICATION REQUIRED - Replace PACKAGE_NAME with your package name -->
    <provider
        android:name="com.urbanairship.UrbanAirshipProvider"
        android:authorities="com.myapp.app.urbanairship.provider"
        android:exported="true"
        android:multiprocess="true"
        android:permission="com.myapp.app.permission.UA_DATA" />

    <!-- OPTIONAL, if you want to receive push, push opened and registration completed intents -->
    <!-- Replace the receiver below with your package and class name -->
    <receiver
        android:name="com.myapp.app.controllers.push.PushIntentReceiver"
        android:exported="false">

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


            <category android:name="com.myapp.app" />
        </intent-filter>
    </receiver>

 <receiver android:name="com.urbanairship.CoreReceiver"
        android:exported="false">

        <intent-filter android:priority="-999">
            <action android:name="com.urbanairship.push.OPENED" />

            <!-- MODIFICATION REQUIRED - Use your package name as the category -->
            <category android:name="com.myapp.app" />
        </intent-filter>
    </receiver>



    <!-- REQUIRED for PlayServiceUtils.handleAnyPlayServicesError to handle Google Play Services recoverable errors. -->
    <activity
        android:name="com.urbanairship.google.PlayServicesErrorActivity"
        android:theme="@android:style/Theme.Translucent.NoTitleBar" />

    <!-- REQUIRED for GCM -->
    <receiver
        android:name="com.urbanairship.push.GCMPushReceiver"
        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" />

            <!-- MODIFICATION REQUIRED - Use your package name as the category -->
            <category android:name="com.myapp.app" />
        </intent-filter>
    </receiver>
    <!-- end Urban Airship tags -->

当 Intent 接收器扩展了基本 Intent Receiver 但没有调用 super 就覆盖了 onReceive,类别的包名称混乱,或者应用程序没有声明和使用 "PACKAGE_NAME.UA_DATA" 许可。 SDK 现在默认自动启动应用程序的启动器 activity,但如果该部分不起作用,则您很可能需要声明权限。

在 AndroidManifest.xml 的清单部分添加:

<permission android:name="com.myapp.app.permission.UA_DATA" android:protectionLevel="signature" />
<uses-permission android:name="com.myapp.app.permission.UA_DATA" />