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

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.

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!

Put facebook avatar url into img[src] doesn't work in Ionic 3

In sample, have two avatar URLs, one of them doesn't show up in ionic app and just do download in browser, instead to open in tab.
So if put this url that doesn't work(1) into [src] attribute, image is not loaded in ionic emulator and in real device, but everything is OK in Chrome.
https://graph.facebook.com/105656846898488/picture?width=200&height=200&redirect=false&type=normal
https://graph.facebook.com/67563683055/picture?width=200&height=200&redirect=false&type=normal
ex. of usage:
<img [src]="user.avatar">
Parse method:
let x = new XMLHttpRequest();
x.open("GET", `https://graph.facebook.com/${facebookUserId}/picture?width=200&height=200&redirect=false`, false);
x.send(null);
return JSON.parse(x.responseText).data.url;
I guess something with facebook server setting, because both images pulled from different server domains.
Image with facebook userid: 67563683055 - work's good.

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.

Issue when calling an application from webApp

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.