Skip to content

Instantly share code, notes, and snippets.

@sitefinitysteve
Created May 12, 2020 19:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sitefinitysteve/b0166045664fee9418d1e53123117909 to your computer and use it in GitHub Desktop.
Save sitefinitysteve/b0166045664fee9418d1e53123117909 to your computer and use it in GitHub Desktop.
import { available } from "nativescript-appavailability";
import { isAndroid, isIOS, device, screen } from "tns-core-modules/platform";
import * as utils from "tns-core-modules/utils/utils";
export function onOpenLink(args){
let link: LinkItem = args.view.bindingContext;
if (link.domain == "facebook.com") {
//FACEBOOK APP
const fbScheme = isIOS ? "fb://" : "com.facebook.katana";
available(fbScheme).then(available => {
if (available) {
if (isIOS) {
openUrl(`fb://profile?id=${link.username}`);
} else {
var url = `fb://facewebmodal/f?href=https://www.facebook.com/${link.username}`;
openUrl(url);
}
} else {
// open in the default browser
var webLink = `https://www.facebook.com/${link.username}`;
openUrl(webLink);
}
});
} else {
//DEFAULT ROUTE
utils.openUrl(link.url);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment