diff --git a/src/urlhandler.android.ts b/src/urlhandler.android.ts index c8d6fb8..762fc2c 100644 --- a/src/urlhandler.android.ts +++ b/src/urlhandler.android.ts @@ -1,6 +1,11 @@ import { AndroidActivityEventData, AndroidActivityNewIntentEventData, AndroidApplication, android as andApp } from '@nativescript/core/application'; -import { _handleURL, extractAppURL } from './urlhandler.common'; -export { handleOpenURL } from './urlhandler.common'; +import { _handleOpenURL, _handleURL, extractAppURL } from './urlhandler.common'; +import { UrlHandlerCallback } from './urlhandler'; +export { _handleOpenURL } from './urlhandler.common'; + +export function handleOpenURL(handler: UrlHandlerCallback): void { + _handleOpenURL(handler); +} export function handleIntent(intent: android.content.Intent, args?) { const data = intent.getData(); diff --git a/src/urlhandler.common.ts b/src/urlhandler.common.ts index d4ba79f..085bfdb 100644 --- a/src/urlhandler.common.ts +++ b/src/urlhandler.common.ts @@ -31,7 +31,7 @@ export function extractAppURL(urlParam: any): AppURL { } } -export function handleOpenURL(handler: UrlHandlerCallback): void { +export function _handleOpenURL(handler: UrlHandlerCallback): void { URL_HANDLER_CB = handler; } @@ -43,11 +43,11 @@ export function getCallback(): UrlHandlerCallback { } return URL_HANDLER_CB; } + export function _handleURL(appURL, args?) { if (!URL_HANDLER_CB) { console.error('No callback provided. Please ensure that you called "handleOpenURL" during application init!'); } else { URL_HANDLER_CB(appURL, args); } - } diff --git a/src/urlhandler.ios.ts b/src/urlhandler.ios.ts index 32c34f9..bb33050 100644 --- a/src/urlhandler.ios.ts +++ b/src/urlhandler.ios.ts @@ -1,12 +1,16 @@ -import { _handleURL, extractAppURL } from './urlhandler.common'; +import { _handleOpenURL, _handleURL, extractAppURL } from './urlhandler.common'; import { getAppDelegate } from './getappdelegate'; -export { handleOpenURL } from './urlhandler.common'; +import { UrlHandlerCallback } from './urlhandler'; + +export function handleOpenURL(handler: UrlHandlerCallback): void { + _handleOpenURL(handler); +} export const appDelegate = getAppDelegate(); function enableMultipleOverridesFor(classRef, methodName, nextImplementation) { const currentImplementation = classRef.prototype[methodName]; - classRef.prototype[methodName] = function () { + classRef.prototype[methodName] = function() { const result = currentImplementation && currentImplementation.apply(currentImplementation, Array.from(arguments)); return nextImplementation.apply(nextImplementation, Array.from(arguments).concat([result])); }; @@ -15,7 +19,7 @@ function enableMultipleOverridesFor(classRef, methodName, nextImplementation) { enableMultipleOverridesFor( appDelegate, 'applicationOpenURLOptions', - function ( + function( application: UIApplication, url: NSURL, options: any @@ -40,7 +44,7 @@ enableMultipleOverridesFor( enableMultipleOverridesFor( appDelegate, 'applicationContinueUserActivityRestorationHandler', - function ( + function( application: UIApplication, userActivity: NSUserActivity, restorationHandler