I send notifications with deep links with URIs which look like this
myscheme://mydata
I have an activity which is configured to handle such URI schema:
<activity
android:name=".MyActivity"
android:noHistory="true"
android:theme="@style/NoActionBar">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="myscheme"/>
</intent-filter>
</activity>
If I click on a UA push notification and my app is in the background, my app's main activity is launched first, and then MyActivity
is launched.
If I click on a UA push notification and my app is in the foreground, only main activity is (re)launched, MyActivity never gets launched.
I have verified that this is only the issue with UA notifications - hand-created notifications work as expected - MyActivity is
properly launched. Verified with this code:
long when = System.currentTimeMillis();
NotificationManager notificationManager = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("myscheme://mydata"));
PendingIntent pendingIntent = PendingIntent.getActivity(context, 555, intent, PendingIntent.FLAG_UPDATE_CURRENT);
Notification.Builder builder = new Notification.Builder(context)
.setSmallIcon(R.drawable.common_launcher)
.setContentTitle("hello")
.setContentText("Hello!")
.setContentIntent(pendingIntent)
.setWhen(when)
.setAutoCancel(false);
notificationManager.notify(System.currentTimeMillis() + "", 33, builder.build());
How can I avoid launching main activity when opening UA notifications with deep links?
Comments
17 comments