/// <summary> /// Just common code used in <seealso cref="#executeNotifAnnouncementAction(EngagementNotifAnnouncement)"/> </summary> private void doExecuteNotifAnnouncementAction(EngagementNotifAnnouncement notifAnnouncement, Intent intent) { intent = onNotifAnnouncementIntentPrepared(notifAnnouncement, intent); if (intent != null) { mContext.startActivity(intent); } }
public virtual void executeNotifAnnouncementAction(EngagementNotifAnnouncement notifAnnouncement) { /* Launch action intent (view activity in its own task) */ try { Intent intent = Intent.parseUri(notifAnnouncement.ActionURL, 0); intent.Flags = Intent.FLAG_ACTIVITY_NEW_TASK; doExecuteNotifAnnouncementAction(notifAnnouncement, intent); } catch (Exception) { /* * Invalid/Missing Action URL: launch/resume application instead if system notification and no * session. */ if (notifAnnouncement.SystemNotification && EngagementActivityManager.Instance.CurrentActivityAlias == null) { PackageManager packageManager = mContext.PackageManager; Intent intent = packageManager.getLaunchIntentForPackage(mContext.PackageName); if (intent != null) { /* * Set package null is the magic enabling the same behavior than launching from Home * Screen, e.g. perfect resume of the task. No idea why the setPackage messes the intent * up... */ if (intent.Component != null) { intent.Package = null; } intent.Flags = Intent.FLAG_ACTIVITY_NEW_TASK; doExecuteNotifAnnouncementAction(notifAnnouncement, intent); } } } }
/// <summary> /// This method is called just before starting the intent associated to the click on a notification /// only announcement: execute the action URL or launch application if no URL and clicked from a /// system notification while application is in background. You can change flags, return a brand /// new intent or return null to cancel the intent and manage it yourself. </summary> /// <param name="notifAnnouncement"> notification only announcement. </param> /// <param name="intent"> prepared intent. </param> /// <returns> intent to launch, pass null to handle launching yourself. </returns> protected internal virtual Intent onNotifAnnouncementIntentPrepared(EngagementNotifAnnouncement notifAnnouncement, Intent intent) { return(intent); }
/// <summary> /// This method is called just before starting the intent associated to the click on a notification /// only announcement: execute the action URL or launch application if no URL and clicked from a /// system notification while application is in background. You can change flags, return a brand /// new intent or return null to cancel the intent and manage it yourself. </summary> /// <param name="notifAnnouncement"> notification only announcement. </param> /// <param name="intent"> prepared intent. </param> /// <returns> intent to launch, pass null to handle launching yourself. </returns> protected internal virtual Intent onNotifAnnouncementIntentPrepared(EngagementNotifAnnouncement notifAnnouncement, Intent intent) { return intent; }