@nativescript/core
Version:
A JavaScript library providing an easy to use api for interacting with iOS and Android platform APIs.
56 lines (55 loc) • 2.74 kB
TypeScript
/**
* Bridges scene delegate callbacks back onto the `UIApplicationDelegate` methods that UIKit
* stops calling once an app adopts scenes, so handlers registered through
* `Application.ios.addDelegateHandler()` keep firing.
*
* `addDelegateHandler` chains handlers onto the delegate *prototype*, so forwarding means
* invoking that prototype method — there is no other entry point to the chain.
*/
/** The app delegate class as `Application.ios.delegate` exposes it. */
type AppDelegateClass = (UIApplicationDelegate & {
prototype: UIApplicationDelegate;
}) | undefined | null;
/**
* Reports a native completion result at most once.
*/
export interface OneShotCompletion {
(handled: boolean): void;
/** Whether the result has already been reported. */
readonly delivered: boolean;
}
/**
* Rebuilds the options dictionary `applicationOpenURLOptions` expects from the scene-side
* {@link UISceneOpenURLOptions}. Keys with no value are left out, matching what UIKit passes.
*/
export declare function buildOpenURLOptions(options: UISceneOpenURLOptions): NSDictionary<string, any>;
/**
* Forwards a scene URL delivery to `applicationOpenURLOptions`.
*
* @returns whether a legacy handler was found and invoked.
*/
export declare function forwardOpenURLContexts(delegate: AppDelegateClass, application: UIApplication, urlContexts: NSSet<UIOpenURLContext>): boolean;
/**
* Forwards a scene activity continuation to `applicationContinueUserActivityRestorationHandler`.
*
* @returns whether a legacy handler was found and invoked.
*/
export declare function forwardContinueUserActivity(delegate: AppDelegateClass, application: UIApplication, userActivity: NSUserActivity): boolean;
/**
* Hands a scene quick action to `applicationPerformActionForShortcutItemCompletionHandler`,
* or reports it unhandled when no such handler is registered.
*
* Together with the repeat-call guard in {@link oneShotCompletion} this is what makes `deliver`
* run exactly once: a legacy handler owns the result when there is one, and the fallback covers
* the case where nothing else would ever report back to iOS.
*
* @returns whether a legacy handler was found and invoked.
*/
export declare function deliverShortcutItem(delegate: AppDelegateClass, application: UIApplication, shortcutItem: UIApplicationShortcutItem, deliver: OneShotCompletion): boolean;
/**
* Wraps a native completion handler so only the first result reaches it. iOS treats a
* completion handler invoked twice as a programming error, and the same handler is exposed
* to both event listeners and legacy delegate handlers.
*/
export declare function oneShotCompletion(completionHandler: (handled: boolean) => void): OneShotCompletion;
export {};