From cd313eb6d2cfeb834f4baf13488ef8ac7fc8154b Mon Sep 17 00:00:00 2001 From: Vladimir Enchev Date: Wed, 9 Sep 2015 10:34:21 +0300 Subject: [PATCH] openUrl added --- utils/utils.android.ts | 7 +++++++ utils/utils.d.ts | 6 ++++++ utils/utils.ios.ts | 11 +++++++++-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/utils/utils.android.ts b/utils/utils.android.ts index 4cd78710b..22e5d63b5 100644 --- a/utils/utils.android.ts +++ b/utils/utils.android.ts @@ -130,4 +130,11 @@ export module ad { export function GC() { gc(); +} + +export function openUrl(url: string): void { + var context = ad.getApplicationContext(); + if (context) { + context.startActivity(new android.content.Intent(android.content.Intent.ACTION_VIEW, android.net.Uri.parse(url))); + } } \ No newline at end of file diff --git a/utils/utils.d.ts b/utils/utils.d.ts index e6b560f42..7c168ee72 100644 --- a/utils/utils.d.ts +++ b/utils/utils.d.ts @@ -173,4 +173,10 @@ * @param source The JSON or JSONP string. */ export function parseJSON(source: string): any + + /** + * Opens url. + * @param url The url. + */ + export function openUrl(url: string): void } diff --git a/utils/utils.ios.ts b/utils/utils.ios.ts index e479ffa07..46485044e 100644 --- a/utils/utils.ios.ts +++ b/utils/utils.ios.ts @@ -50,7 +50,7 @@ export module ios { var greenRef = new interop.Reference(); var blueRef = new interop.Reference(); var alphaRef = new interop.Reference(); - + uiColor.getRedGreenBlueAlpha(redRef, greenRef, blueRef, alphaRef); var red = redRef.value * 255; var green = greenRef.value * 255; @@ -142,8 +142,15 @@ export module ios { rootView.measure(widthSpec, heightSpec); rootView.layout(left, top, width, height); } -} +} export function GC() { __collect(); +} + +export function openUrl(url: string): void { + var sharedApp = UIApplication.sharedApplication() + if (sharedApp) { + sharedApp.openURL(NSURL.URLWithString(url)); + } } \ No newline at end of file