Reputation: 44228
I am extending BaseIntentReceiver
into a new class PushIntentReceiver
, intended to take different actions from the key/value pairs within push notification objects.
Although my push notifications display correctly, PushIntentReceiver never gets called. Therefore clicking a notification seems to do nothing. Every method has a log tag inside of it, such as
@Override
protected void onBackgroundPushReceived(Context context, PushMessage message) {
Log.i(TAG, "Received background push message: " + message);
}
but none of this appears in LogCat. Whether it is the registration method, or the notification clicked method or anything. Similarly my breakpoints do not get hit in these functions.
Why is this? I’ve included the relevant parts of my AndroidManifest. The previous version of UrbanAirship that was in this app was the version where Amazon UA was split from Android UA when you guys first created the Amazon UA. So I don’t know if that was Android UA 5.0 or 4.x , but my Push Notification interception via BroadcastReceivers did work in that old version of the library. Now everything has been restructured to the UA 5.1.x+ ways and I can’t get it to work.
Insight appreciated
This is the relevant portion of my 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 -->
Upvotes: 2
Views: 1230
Reputation: 1766
Problems like these usually happen when the intent receiver extends the base intent receiver but overrides onReceive without calling through to super, the package name is messed up for the category, or the app does not declare and use the "PACKAGE_NAME.UA_DATA" permission. The SDK now automatically launches the application's launcher activity by default, but if that part is not working then you most likely need to declare the permission.
In the manifest section of the AndroidManifest.xml add:
<permission android:name="com.myapp.app.permission.UA_DATA" android:protectionLevel="signature" />
<uses-permission android:name="com.myapp.app.permission.UA_DATA" />
Upvotes: 2