Created
May 12, 2020 19:19
-
-
Save sitefinitysteve/b0166045664fee9418d1e53123117909 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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