Skip to content
This repository was archived by the owner on Apr 15, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/urlhandler.android.ts
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/urlhandler.common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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);
}

}
14 changes: 9 additions & 5 deletions src/urlhandler.ios.ts
Original file line number Diff line number Diff line change
@@ -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]));
};
Expand All @@ -15,7 +19,7 @@ function enableMultipleOverridesFor(classRef, methodName, nextImplementation) {
enableMultipleOverridesFor(
appDelegate,
'applicationOpenURLOptions',
function (
function(
application: UIApplication,
url: NSURL,
options: any
Expand All @@ -40,7 +44,7 @@ enableMultipleOverridesFor(
enableMultipleOverridesFor(
appDelegate,
'applicationContinueUserActivityRestorationHandler',
function (
function(
application: UIApplication,
userActivity: NSUserActivity,
restorationHandler
Expand Down