Xam.Plugins.Notifier: Android Tap in Xamarin.Forms.Shell

IanVinkIanVink ✭✭✭CAInsider, University ✭✭✭

Using Xam.Plugins.Notifier for Local Notifications I am able to show a notification in Android. However, when I tap the notification, it reloads the application. Similar to how a remote notification would.

I handle the OnNewIntent() in the MainActivitiy.cs but it never fires.

How do I tap a Local Notification made by Xam.Plugins.Notifier so that OnNewIntent() fires and I can show a Shell item?

    protected async override void OnNewIntent(Intent intent)
    {
        base.OnNewIntent(intent);
        var title = intent.GetStringExtra("title");
        if (title != null)
        {
            await Shell.Current.GoToAsync("Tools/Sales");
        }
    }

Answers

  • IanVinkIanVink ✭✭✭ CAInsider, University ✭✭✭
    edited July 18

    Note that I have a SplashScreen Activity that actually starts the app:

    How do I pass the Intent that starts the activity to the MainActitity from the Splash

     [Activity(Theme = "@style/MyTheme.Splash", MainLauncher = true, NoHistory = true, LaunchMode = 
     Android.Content.PM.LaunchMode.SingleTop)]
    public class SplashActivity : AppCompatActivity
    {
    
    
    public override void OnCreate(Bundle savedInstanceState, PersistableBundle persistentState)
    {
        base.OnCreate(savedInstanceState, persistentState);
    }
    
    // Launches the startup task
    protected override void OnResume()
    {
        base.OnResume();
        StartActivity(new Intent(Application.Context, typeof(MainActivity)));
    }
    
    public override void OnBackPressed() { }
    
    
    }
    
Sign In or Register to comment.