Skip to content

Commit 875b82a

Browse files
authored
Merge pull request #103 from OneSignal/cd_update
Generator Update
2 parents bfe8cbd + b5e1460 commit 875b82a

File tree

1 file changed

+41
-34
lines changed

1 file changed

+41
-34
lines changed

index.ts

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ addSDKScript();
1515
declare global {
1616
interface Window {
1717
OneSignalDeferred?: OneSignalDeferredLoadedCallback[];
18+
OneSignal?: IOneSignalOneSignal;
1819
safari?: {
1920
pushNotification: any;
2021
};
@@ -143,58 +144,61 @@ interface IInitObject {
143144
}
144145

145146
interface IOneSignalOneSignal {
146-
login(externalId: string, jwtToken?: string): Promise<void>
147-
logout(): Promise<void>
148-
init(options: IInitObject): Promise<void>
149-
setConsentGiven(consent: boolean): Promise<void>
150-
setConsentRequired(requiresConsent: boolean): Promise<void>
151147
Slidedown: IOneSignalSlidedown;
152148
Notifications: IOneSignalNotifications;
153149
Session: IOneSignalSession;
154150
User: IOneSignalUser;
155151
Debug: IOneSignalDebug;
152+
login(externalId: string, jwtToken?: string): Promise<void>;
153+
logout(): Promise<void>;
154+
init(options: IInitObject): Promise<void>;
155+
setConsentGiven(consent: boolean): Promise<void>;
156+
setConsentRequired(requiresConsent: boolean): Promise<void>;
156157
}
157158
interface IOneSignalNotifications {
158-
setDefaultUrl(url: string): Promise<void>
159-
setDefaultTitle(title: string): Promise<void>
160-
isPushSupported(): boolean
161-
getPermissionStatus(onComplete: Action<NotificationPermission>): Promise<NotificationPermission>
162-
requestPermission(): Promise<void>
163-
addEventListener(event: NotificationEventName, listener: (obj: any) => void): void
164-
removeEventListener(event: NotificationEventName, listener: (obj: any) => void): void
159+
setDefaultUrl(url: string): Promise<void>;
160+
setDefaultTitle(title: string): Promise<void>;
161+
isPushSupported(): boolean;
162+
getPermissionStatus(onComplete: Action<NotificationPermission>): Promise<NotificationPermission>;
163+
requestPermission(): Promise<void>;
164+
addEventListener(event: NotificationEventName, listener: (obj: any) => void): void;
165+
removeEventListener(event: NotificationEventName, listener: (obj: any) => void): void;
165166
}
166167
interface IOneSignalSlidedown {
167-
promptPush(options?: AutoPromptOptions): Promise<void>
168-
promptPushCategories(options?: AutoPromptOptions): Promise<void>
169-
promptSms(options?: AutoPromptOptions): Promise<void>
170-
promptEmail(options?: AutoPromptOptions): Promise<void>
171-
promptSmsAndEmail(options?: AutoPromptOptions): Promise<void>
172-
addEventListener(event: SlidedownEventName, listener: (wasShown: boolean) => void): void
173-
removeEventListener(event: SlidedownEventName, listener: (wasShown: boolean) => void): void
168+
promptPush(options?: AutoPromptOptions): Promise<void>;
169+
promptPushCategories(options?: AutoPromptOptions): Promise<void>;
170+
promptSms(options?: AutoPromptOptions): Promise<void>;
171+
promptEmail(options?: AutoPromptOptions): Promise<void>;
172+
promptSmsAndEmail(options?: AutoPromptOptions): Promise<void>;
173+
addEventListener(event: SlidedownEventName, listener: (wasShown: boolean) => void): void;
174+
removeEventListener(event: SlidedownEventName, listener: (wasShown: boolean) => void): void;
174175
}
175176
interface IOneSignalDebug {
176-
setLogLevel(logLevel: string): void
177+
setLogLevel(logLevel: string): void;
177178
}
178179
interface IOneSignalSession {
179-
sendOutcome(outcomeName: string, outcomeWeight?: number): Promise<void>
180-
sendUniqueOutcome(outcomeName: string): Promise<void>
180+
sendOutcome(outcomeName: string, outcomeWeight?: number): Promise<void>;
181+
sendUniqueOutcome(outcomeName: string): Promise<void>;
181182
}
182183
interface IOneSignalUser {
183-
addAlias(label: string, id: string): void
184-
addAliases(aliases: { [key: string]: string }): void
185-
removeAlias(label: string): void
186-
removeAliases(labels: string[]): void
187-
addEmail(email: string): void
188-
removeEmail(email: string): void
189-
addSms(smsNumber: string): void
190-
removeSms(smsNumber: string): void
191184
PushSubscription: IOneSignalPushSubscription;
185+
addAlias(label: string, id: string): void;
186+
addAliases(aliases: { [key: string]: string }): void;
187+
removeAlias(label: string): void;
188+
removeAliases(labels: string[]): void;
189+
addEmail(email: string): void;
190+
removeEmail(email: string): void;
191+
addSms(smsNumber: string): void;
192+
removeSms(smsNumber: string): void;
192193
}
193194
interface IOneSignalPushSubscription {
194-
optIn(): Promise<void>
195-
optOut(): Promise<void>
196-
addEventListener(event: 'subscriptionChange', listener: (change: SubscriptionChangeEvent) => void): void
197-
removeEventListener(event: 'subscriptionChange', listener: (change: SubscriptionChangeEvent) => void): void
195+
id: string | null | undefined;
196+
token: string | null | undefined;
197+
optedIn: boolean | undefined;
198+
optIn(): Promise<void>;
199+
optOut(): Promise<void>;
200+
addEventListener(event: 'subscriptionChange', listener: (change: SubscriptionChangeEvent) => void): void;
201+
removeEventListener(event: 'subscriptionChange', listener: (change: SubscriptionChangeEvent) => void): void;
198202
}
199203

200204
function oneSignalLogin(externalId: string, jwtToken?: string): Promise<void> {
@@ -601,6 +605,9 @@ function debugSetLogLevel(logLevel: string): void {
601605
});
602606
}
603607
const PushSubscriptionNamespace: IOneSignalPushSubscription = {
608+
get id(): string | null | undefined { return window.OneSignal?.User?.PushSubscription?.id },
609+
get token(): string | null | undefined { return window.OneSignal?.User?.PushSubscription?.token },
610+
get optedIn(): boolean | undefined { return window.OneSignal?.User?.PushSubscription?.optedIn },
604611
optIn: pushSubscriptionOptIn,
605612
optOut: pushSubscriptionOptOut,
606613
addEventListener: pushSubscriptionAddEventListener,

0 commit comments

Comments
 (0)