How to choose and open available navigation app from Xamarin iOS? - ios

I have the following code to open Navigation App from one of the button click in my content page.
var location = new Location(Convert.ToDouble(jobItem.Latitude), Convert.ToDouble(jobItem.Longitude));
var options = new MapLaunchOptions { NavigationMode = NavigationMode.Driving };
await Map.OpenAsync(location, options);
There are Google Maps and Waze in my android phone, so the code above did show the selection panel and let user to choose which app to use which is no issue. However, when this meet iOS, it straight away open Apple Maps without any selection even though there are 3 navigation apps in the iPhone. I have tried to research to deal with the default navigation app setting on iOS but unfortunately iOS didn't provide any single option to set the app as default unlike android. What else I can do?

You could use the Xamarin.Essentials: Launcher NuGet package.
You'd need to modify the code to look something like the below pseudocode
var supportsWaze = await Launcher.CanOpenAsync("whateverTheWazeUriSchemeIs://");
var supportsGoogleMaps = await Launcher.CanOpenAsync("whateverTheUriSchemeIs://");
You'd then need to give the user some sort of UI for them to select a mapping app based upon these boolean(s) being true. I'd use an ActionSheet
Then you can use the await Launcher.OpenAsync method to open the correct URI based on whatever choice the user made. You could offer them the option to remember this choice for later as well.
iOS wont allow you to override the OS default apps, but within your own app you can choose how other applications are launched. The Google applications are a good example of this.

Related

iOS - Opening Search App programmatically

I would like to know how it is possible to search something on iOS devices programmatically (Spotlight?) using Universal links or direct methods (native code) to open the search app like on Android.
In my Android app I have
String string = query;
Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
intent.setPackage("com.google.android.googlequicksearchbox");
intent.setClassName("com.google.android.googlequicksearchbox", "com.google.android.googlequicksearchbox.SearchActivity");
intent.putExtra("query", string);
activity.startActivity(intent);
This code performs a search that sometimes allows assistant-like results with the possibility to open relevant apps or the web browser and so on.
I think also iOS have this feature. How to do that?
You can make your app searchable with Siri, but you cannot, in code, trigger a Siri search.

How to accept the google permission prompt by default while using appium

I'm trying to automate the app , but suddenly in middle the google permissions window for permission like phone , location etc pops up , is there any way that I can make sure always permission pop ups are allowed
Try to set desired capabilities:
autoAcceptAlerts = true
Since you said google permissions, I am assuming you are dealing in Android. Also since there is no language tag, I am sticking to Java, you can frame the logic in any language you are using.
Well, its sad to inform you that currently there seems to be no such capability added for android. Though iOS has few similar capabilities.
So, for android what you can do is logically -
If these pop-ups are device dependent, change the device settings that these pop-ups are not allowed.
If these pop-ups are relevant to application permissions, then you must know when they would occur. Just keep a check -
List<WebElement> popUp = driver.findElement(<find the pop up using your locator strategy>);
if(popUp.size()!=0) {
WebElement accept/dismiss = driver.findElement(<find the button accordingly>);
accept/dismiss.click();
}

How to share URL using Xamarin iOS

I'm developing an app for my local newspaper. When you press the "Share" button, I want the standard iOS share interface to appear allowing users to share the URL of an article with Facebook, Twitter, etc. I'm trying to use the UIActivityViewController, and while it appears, it's not giving me all of the options.
Here's the code I use:
NSObject[] activitiesItems = {
new NSString(post.Title),
new NSUrl(post.URL)
};
var activityController = new UIActivityViewController(activitiesItems, null);
PresentViewController(activityController, true, null);
When the UI opens, this is all I see (no Twitter or Facebook):
This is in comparison to what I see when I share a page from Safari, which has the Facebook and Twitter options, along with a variety of others:
What do I have to change in my code to allow more of these options to appear?
1) Your code is fine
2) On your iOS Simulator go to the Setting and login to Twitter and/or FaceBook accounts and retest your app.
iOS Simulator Setting (botton off screen):
Here is my Simulator view with me logged into Twitter but not Facebook using the same code you posted:
3) Safari is a using a custom ViewController to display what you are seeing... If you actually try to share a link via that Twitter button you will be force to login..
4) Use an actual device for complete testing of all the possible sharing applications installed.
Those options are only supposed to show when you are logged in to an account in the Settings app for FB and Twitter. They are hidden if not.
However that doesn't really explain why they show up in Safari.
Perhaps including the NSString for post.Title in the items array is causing it to exclude some sharing options.

Change Safari URL with App Extension

When the icon of my Safari app extension icon is touched, I want to change the URL without showing a new view. Doing this comes down to two issues:
How can I use an safari app extension without showing a new view? I just want to perform a background action when the extension icon is pressed.
How can I change the current URL in Safari?
Actually, you might be able to change the URL at the finalize function of your ExtensionPreprocessingJS file
// Note that the finalize function is only available in iOS.
finalize: function(arguments) {
// arguments contains the value the extension provides in
[NSExtensionContext completeRequestReturningItems:completion:].
// In this example, the extension provides a color as a returning item.
document.URL = arguments["newUrl"];
}
It seems like what you're describing is a bookmark, and not an app extension. I would highly doubt that app extensions would allow you to interface with Safari and update the URL, this would be wrong in many regards, including privacy and security. In short, not possible (sorry).

How to launch AppWorld from an application? [BlackBerry]

This might be a easy question but i couldn't find solution. I want to open AppWorld by clicking a button in my BB application. For example when user clicks this button Appworld will show "Facebook Application" page. Can i do this?
In Android platform this line launches GooglePlay for Facebook App. Does BlackBerry supports this kind of method?
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.facebook.katana")));
Here is a simple way to do this:
Browser.getDefaultSession().displayPage("http://appworld.blackberry.com/webstore/content/2360/?lang=en");
Above code will invoke the browser in the application and open the BlackBerry App World, I tested it in device and it's perfectly working. For now I put a Whats App messenger link, but you can customize the link according to your requirement.
You can open App World from your BB application directly using the following code. This code avoids opening the browser first.
Registry registry = Registry.getRegistry(this.getClass().getName());
Invocation invocation = new Invocation(null, null,
"net.rim.bb.appworld.Content",
false, ContentHandler.ACTION_OPEN);
invocation.setArgs(new String[] { /* app id in appworld */ });
registry.invoke(invocation);

Resources