Can someone tell me the best approach to accomplishing this for IOS and Android. Code samples or links to related discussions would be most appreciated.
Need to find the package name of the application on your device. Then open the app using the package name and any Intents you need to pass to it. If you device is not rooted find the packages that are installed or use a simulator to find the package names or use the code below to list all package names on the device.
var pm = Android.App.Application.Context.PackageManager;
pm.GetPackageInfo(package, 0);
uri = Android.Net.Uri.Parse(packageurl);
var intent = new Intent (Intent.ActionView, uri);
// any IntentFlags or Data
this.StartActivity (intent);
public static void StartActivity(this object o, Intent intent)
{
var context = o as Context;
if (context != null)
{
context.StartActivity (intent);
}
else
{
intent.SetFlags (ActivityFlags.NewTask);
Application.Context.StartActivity (intent);
}
}
@AndrewMcCormack Thank you for the response. Overall, I am not following the code you pasted, other than it apears to be specific to android. I am using Xamarin forms and should have stated that in my posted. With that I need a solution at the PCL level and specific platforms, IOS and Android.
HI @KenNickerson did you find a solution to this.
I am using xamarin forms as well and need to detect if an app is present on my device else need to go to respective stores and install the app.
I am looking for something at PCL level too for android and IOS.
@CodingNewUser Not sure what your question is. Are you asking how to open an app from the browser or from another app. I posted the code if from another app
uri would be something like someapp:// or itunes:// for example
Yes I'm asking how to open an app from another app..From where can we get the uri for the applications.
In android we have several apps available on playstore which give the information of the package name.Do we have something similar for IOS as well? @KenNickerson
@SudharsanC Do you have the correct iOS app name, as the device would recognize it. This may not be the same as the viewable appname. What app are you trying to detect?
The app name in your PCL project needs to look like the following:
var appname = @"otherappId://";
The appname may also include parameters where the app supports multiple organizations
Also, this might be the issue.
You may also need the following in info.plist:
-- < key > LSApplicationQueriesSchemes
-- < array >
-- < string > appname < /string >
-- < /array
Answers
Need to find the package name of the application on your device. Then open the app using the package name and any Intents you need to pass to it. If you device is not rooted find the packages that are installed or use a simulator to find the package names or use the code below to list all package names on the device.
Open app
@AndrewMcCormack Thank you for the response. Overall, I am not following the code you pasted, other than it apears to be specific to android. I am using Xamarin forms and should have stated that in my posted. With that I need a solution at the PCL level and specific platforms, IOS and Android.
HI @KenNickerson did you find a solution to this.
I am using xamarin forms as well and need to detect if an app is present on my device else need to go to respective stores and install the app.
I am looking for something at PCL level too for android and IOS.
IN THE HANDLER:
IN THE IOS PROJECT:
IN THE ANDROID PROJECT:
For ios what is the uri..any way to get the uri installed on an ios device
@CodingNewUser Not sure what your question is. Are you asking how to open an app from the browser or from another app. I posted the code if from another app
uri would be something like someapp:// or itunes:// for example
In android we have several apps available on playstore which give the information of the package name.Do we have something similar for IOS as well?
@KenNickerson
How is described above. What app do you want to open. DO you know who authored it? Is it an Apple owned app?
In any case, n most cases it should be the name of the app followed by //:
For Example- there is an app yammer on app store,then will this work?
var canOpen = UIApplication.SharedApplication.CanOpenUrl(new NSUrl(yammer://));
For some apps i know who authored it but some of them would be general applications on Appstore.
Probably but not guaranteed. Give it a shot. GL
For iOS, Destination application not launched. I was followed the same that what your are mentioned above.
@SudharsanC Do you have the correct iOS app name, as the device would recognize it. This may not be the same as the viewable appname. What app are you trying to detect?
The app name in your PCL project needs to look like the following:
The appname may also include parameters where the app supports multiple organizations
Also, this might be the issue.
You may also need the following in info.plist:
-- < key > LSApplicationQueriesSchemes
-- < array >
-- < string > appname < /string >
-- < /array
Thanks @KenNickerson for your post.
This one is also helpful for iOS.
Hi all, anybody knows how to launch default Contacts app from our app in iOS.
Thanks in advance.
@Xnaina Try contacts://
Just a guess