Example #1
0
        protected virtual PendingIntent GetLaunchPendingIntent(Notification notification, string actionId = null)
        {
            var launchIntent = this
                               .context
                               .AppContext
                               .PackageManager
                               .GetLaunchIntentForPackage(this.context.Package.PackageName)
                               .SetFlags(notification.Android.LaunchActivityFlags.ToNative());

            var notificationString = this.serializer.Serialize(notification);

            launchIntent.PutExtra(AndroidNotificationProcessor.NOTIFICATION_KEY, notificationString);
            if (notification.Payload != null)
            {
                // TODO: payload!
                //launchIntent.PutExtra("Payload", notification.Payload);
            }

            PendingIntent pendingIntent;

            if ((notification.Android.LaunchActivityFlags & AndroidActivityFlags.ClearTask) != 0)
            {
                pendingIntent = TaskStackBuilder
                                .Create(this.context.AppContext)
                                .AddNextIntent(launchIntent)
#if ANDROIDX
                                .GetPendingIntent(notification.Id, (int)PendingIntentFlags.OneShot);
Example #2
0
        protected virtual PendingIntent GetLaunchPendingIntent(Notification notification, string?actionId = null)
        {
            Intent launchIntent;

            if (notification.Android?.LaunchActivityType == null)
            {
                launchIntent = this.context
                               .AppContext
                               .PackageManager
                               .GetLaunchIntentForPackage(this.context.Package.PackageName)
                               .SetFlags(notification.Android.LaunchActivityFlags.ToNative());
            }
            else
            {
                launchIntent = new Intent(this.context.AppContext, notification.Android.LaunchActivityType);
            }

            var notificationString = this.serializer.Serialize(notification);

            launchIntent.PutExtra(AndroidNotificationProcessor.NOTIFICATION_KEY, notificationString);
            if (notification.Payload != null)
            {
                foreach (var item in notification.Payload)
                {
                    launchIntent.PutExtra(item.Key, item.Value);
                }
            }

            PendingIntent pendingIntent;

            if ((notification.Android.LaunchActivityFlags & AndroidActivityFlags.ClearTask) != 0)
            {
                pendingIntent = TaskStackBuilder
                                .Create(this.context.AppContext)
                                .AddNextIntent(launchIntent)
#if ANDROIDX
                                .GetPendingIntent(notification.Id, (int)PendingIntentFlags.OneShot);