Issue when calling an application from webApp - iphone

I Create a web application that when I click on button this open another application installed on iphone.
I call another application with this code:
window.launchAPP = function()
{
setTimeout(function()
{
window.location = 'http://www.app.com/'
}, 500);
window.location = 'app://';
};
This work fine if my webapp is called from safari. If I call webapp from my menu, after "add to home screen", other application is not called and I have this error message: "cannot open app. App could not be opened. the error was the url can't be shown:".
Where is my mistake???

Launching Your Own Application via a Custom URL Scheme
Like in android the best choice is registering your custom URL Scheme.

Related

Opening Google calendar from Flutter app (Deep Linking)

I want to open Google calendar app more specifically the create event page in the app from my another flutter app.
I am using the URL launcher package but it opens the app in chrome
What change should I make in the URL so that the add event page opens directly in the google calendar app.
Currently my URL looks like below
https://calendar.google.com/calendar/u/0/r/eventedit?dates=20210226T033000/20210226T040000&ctz=Asia/Calcutta&location&text=Blawsome:+A+Crystal+Alchemy+Healing+Meditation&details=Parth+Pitroda
My code for that part is as below
if (await canLaunchUrl(Uri.parse('https://calendar.google.com/calendar/u/0/r/eventedit?dates=20210226T033000/20210226T040000&ctz=Asia/Calcutta&location&text=Blawsome:+A+Crystal+Alchemy+Healing+Meditation&details=Parth+Pitroda'))) {
await launchUrl(
Uri.parse('https://calendar.google.com/calendar/u/0/r/eventedit?dates=20210226T033000/20210226T040000&ctz=Asia/Calcutta&location&text=Blawsome:+A+Crystal+Alchemy+Healing+Meditation&details=Parth+Pitroda'),
mode: LaunchMode.externalApplication);
} else {
throw 'Could not launch URL';
}
rathe than using a HTTP request, you could use googleapis package from https://pub.dev which has inbuilt methods to create Google Calender events directly within the Calender app.
Check package and documentation here.
Happy coding!

How to launch external opened app using custom URL scheme from Ionic App?

I want to launch opened app B externally from ionic app A using custom URL scheme.
Solutions Tried
Plugin In App Browser, is able to launch external app in the ionic app itself instead of launching the opened external app.
const target = '_system';
let url = 'abc123://abc.com/mobile/details/' + Id;
const options: InAppBrowserOptions = {
zoom: 'no',
location: 'no',
hidden: 'yes'
};
this.loadingProvider.dismiss();
this.inAppBrowserRef = this.inAppBrowser.create(url, target, options);
Plugin App Launcher. For android, it is able to launch external app but use package name instead of custom URL scheme
I use an anchor tag in my template, and set target="_blank". This is from an Ionic 5 app, but I've only tested in the full iOS build, I don't have an Android one yet. I'm also using Capacitor, but I don't think that changes the browser behavior.
<a [href]="website" target="_blank">{{ website }}</a>
The target="_blank" causes it to open the URL in the main os browser. The main browser should then handle your custom link.
If you have custom URL to open use
window.open('Your URL','_system');
in your code. This can be work in both platform Android and ios Perfectly.

how to stay in the webview with intel-sdk crosswalk?

I have below code to open a new browser window which is external URL other than the my applcation
<button id="button" onclick="window.location='http://www.google.com';">click</button>
Problem is: How can I stay within the browser when I open an http url ?
I crosswalk version10, -latest intel-xdk -
function onDeviceReady() {
if( navigator.splashscreen && navigator.splashscreen.hide ) { // Cordova hide splashscreen detected, use it
navigator.splashscreen.hide() ;
alert("Device is ready !");
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');
alert("Started");
}
}
document.addEventListener("deviceready", onDeviceReady, false) ; // ignored by "Standard HTML5 web app"
</script>
I have the first alert "Device is ready");
but it never navigates to apache.org and I never got the second alert !
I added in App Browser (0.5.4) into Cordova included plugins.
In general, it is best to use the inAppBrowser plugin when trying to open URLs within a Cordova app (you are building Cordova apps with the Intel XDK). There are several open options associated with that plugin and it will give you the control you need.

Ajax call to check if native iPhone application exists on the device?

For our iPhone native application we have a URL : example://
On the iPhone if I type this URL (example://) in safari it automatically opens up my application.
From my "regular" website I have a link which when the user clicks it opens the application. The problem is that if the application is not installed on the iPhone it throws "Unable to open" error.
So before rendering the link on my "regular" site I need to check if the app is installed, one solution is to make an Ajax call and check for status code:
$.ajax({
type: 'POST',
url: 'example://',
complete: function (transport) {
if (transport.status == 200) {
alert('Success');
} else {
alert(transport.status);
alert('Failed');
}
}
});
But this code is always returning a status code "0".
Is there a way to find out from the web if the native iPhone app is installed?
If u are referring to Mobile Safari, you're out of luck. There's no documented public API that I know of that can do this. Mobile Safari is sandboxed away from the OS.
If it's in a webview within an app, u can request the URL and let the webview delegate talk to the native app / query the handling of example://. Otherwise, no way the browser can know existence of any installed app.

phonegap Application Location Accessing Issue?

In my phonegap iPhone app, while i am trying to load a html with google maps acces using sencha-touch. A notification shows "/iphone simulator/...../index.html access your Location" . How can i change the html file name to application name?.
Make sure you are calling "navigator.geolocation.getCurrentPosition" after phonegap initialization is done. So for example:
document.addEventListener('deviceready', function () {
navigator.geolocation.getCurrentPosition(successCallback, errorCallback);
}, false);
If that still doesn't do the trick, try adding a delay.