in android, it can setup the deeplink to launch an Activity when receives the push notification.
<activity
android:name=".ActivityForTestAction"
android:launchMode="singleTop"
>
<intent-filter >
<action android:name="demoapp.action.WRITE_TO_DATABASE" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="demoapp"
android:host="www.demoapp.com"
android:pathPrefix="/test" />
</intent-filter>
and it will just build the notification with "demoapp.action.WRITE_TO_DATABASE" and proper Uri:
Intent intent = new Intent("demoapp.action.WRITE_TO_DATABASE");
intent.setData(Uri.parse("demoapp://www.demoapp.com/test"));
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
builder = new Notification.Builder(context)
.setContentIntent(pendingIntent)
... ...;
Notification notification = builder.build();
notificationManager.notify(100, notification);
it will open the ActivityForTestAction
if tap on the notification.
however, there is case that some of the push notification does not need any ui (Activity), for example, just need to write to database.
So is there a way to still do the "deeplink" but instantiate the class and run the action there?