0

I am developing an application with xamarin forms for android and ios. One of requeriments of the app is to react certain links from e-mail. I am able to react to these links and make the logic in the application but I need to bring the application to front.

Is there any way to do that?

Thank you in advance. Sorry for my english.

Best regards.

  • Not sure but is this post perhaps helpful? https://stackoverflow.com/questions/44945166/xamarin-forms-app-return-data-to-calling-app#comment76958292_44945166 – Jordy Dieltjens Aug 24 '17 at 14:33

2 Answers2

0

You want to look for a custom URL scheme and deep linking.

With a custom URL scheme you can register for yourapp://value1/value2. Then whenever someone opens a link from e-mail or wherever which starts with yourapp:// your app will be launched.

With deep linking you can even respond to 'normal' URL's. Like when you tap a Facebook profile link and your app gets opened, that is deep linking.

Gerald Versluis
  • 30,492
  • 6
  • 73
  • 100
0

In Xamarin.Forms for Android

After you get request in MainActivity or SplashActivity by URL Scheme

 protected override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     var data = Intent?.Data?.EncodedAuthority;
     if (data != null)
     {
        Finish();
        ActivityManager am = (ActivityManager)GetSystemService(Context.ActivityService);
        IEnumerable<RunningTaskInfo> tasklist = am.GetRunningTasks(100);
        am.MoveTaskToFront(tasklist.First().Id, 0);
     }
     else
     {
        //....
     }
 }

You need to add

 "android.permission.REORDER_TASKS"
 "android.permission.GET_TASKS"

to AndroidManifest.xml

http://summarynote.blogspot.com/2013/10/android-how-to-bring-app-in-background.html

vvvvv
  • 25,404
  • 19
  • 49
  • 81
user193679
  • 181
  • 2
  • 6