| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- import { InjectionToken } from '@angular/core';
- import { Capacitor, PluginListenerHandle, registerPlugin } from '@capacitor/core';
- export interface JPushStatus {
- available: boolean;
- started: boolean;
- reason?: string;
- }
- export interface JPushNotice {
- kind: 'notification' | 'message';
- messageId: string;
- businessKey?: string;
- title?: string;
- body?: string;
- deepLink?: string;
- }
- export interface JPushPlugin {
- getStatus(): Promise<JPushStatus>;
- start(options: { privacyConsent: boolean }): Promise<JPushStatus>;
- stop(): Promise<void>;
- getRegistrationId(): Promise<{ registrationId: string | null }>;
- setAlias(options: { alias: string }): Promise<void>;
- deleteAlias(): Promise<void>;
- addListener(
- event: 'registration',
- listener: (data: { registrationId: string }) => void,
- ): Promise<PluginListenerHandle>;
- addListener(
- event: 'notificationReceived' | 'notificationOpened',
- listener: (data: JPushNotice) => void,
- ): Promise<PluginListenerHandle>;
- }
- export const JPUSH_OPTIONS = new InjectionToken<{ enabled: boolean }>('JPUSH_OPTIONS', {
- providedIn: 'root',
- factory: () => ({ enabled: false }),
- });
- export const JPUSH_PLUGIN = new InjectionToken<JPushPlugin>('JPUSH_PLUGIN', {
- providedIn: 'root',
- factory: () => registerPlugin<JPushPlugin>('FmodeJPush'),
- });
- export const JPUSH_SUPPORTED = new InjectionToken<() => boolean>('JPUSH_SUPPORTED', {
- providedIn: 'root',
- factory: () => () =>
- Capacitor.getPlatform() === 'android' && Capacitor.isPluginAvailable('FmodeJPush'),
- });
|