Skip to content

Commit b3143a0

Browse files
authored
Merge pull request #82 from OneSignal/fg/update-object-types
More Clean Object Types
2 parents 3d65727 + 2f7b6a6 commit b3143a0

File tree

2 files changed

+372
-8
lines changed

2 files changed

+372
-8
lines changed

src/scaffolds/angular-workspace/projects/onesignal-ngx/src/lib/onesignal-ngx.service.ts

Lines changed: 186 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,193 @@ export interface IInitObject {
129129
appId: string;
130130
subdomainName?: string;
131131
requiresUserPrivacyConsent?: boolean;
132-
promptOptions?: object;
133-
welcomeNotification?: object;
134-
notifyButton?: object;
132+
promptOptions?: {
133+
slidedown: {
134+
prompts: {
135+
/**
136+
* Whether to automatically display the prompt.
137+
* `true` will display the prompt based on the delay options.
138+
* `false` will prevent the prompt from displaying until the Slidedowns methods are used.
139+
*/
140+
autoPrompt: boolean;
141+
142+
/**
143+
* Only available for type: category. Up to 10 categories.
144+
* @example
145+
* categories: [{ tag: 'local_news', label: 'Local News' }] // The user will be tagged with local_news but will see "Local News" in the prompt.
146+
*/
147+
categories: {
148+
/** Should identify the action. */
149+
tag: string;
150+
151+
/** What the user will see. */
152+
label: string;
153+
}[];
154+
155+
/**
156+
* The delay options for the prompt.
157+
* @example delay: { pageViews: 3, timeDelay: 20 } // The user will not be shown the prompt until 20 seconds after the 3rd page view.
158+
*/
159+
delay: {
160+
/** The number of pages a user needs to visit before the prompt is displayed. */
161+
pageViews?: number;
162+
163+
/** The number of seconds a user needs to wait before the prompt is displayed.Both options must be satisfied for the prompt to display */
164+
timeDelay?: number;
165+
};
166+
167+
/**
168+
* The text to display in the prompt.
169+
*/
170+
text?: {
171+
/** The callout asking the user to opt-in. Up to 90 characters. */
172+
actionMessage?: string;
173+
174+
/** Triggers the opt-in. Up to 15 characters. */
175+
acceptButton?: string;
176+
177+
/** Cancels opt-in. Up to 15 characters. */
178+
cancelMessage?: string;
179+
180+
/** The message of the confirmation prompt displayed after the email and/or phone number is provided. Up to 90 characters. */
181+
confirmMessage?: string;
182+
183+
/** Identifies the email text field. Up to 15 characters. */
184+
emailLabel?: string;
185+
186+
/** Cancels the category update. Up to 15 characters. */
187+
negativeUpdateButton?: string;
188+
189+
/** Saves the updated category tags. Up to 15 characters. */
190+
positiveUpdateButton?: string;
191+
192+
/** Identifies the phone number text field. Up to 15 characters. */
193+
smsLabel?: string;
194+
195+
/** A different message shown to subscribers presented the prompt again to update categories. Up to 90 characters. */
196+
updateMessage?: string;
197+
};
198+
199+
/**
200+
* The type of prompt to display.
201+
* `push` which is the Slide Prompt without categories.
202+
* `category` which is the Slide Prompt with categories.
203+
* `sms` only asks for phone number.
204+
* `email` only asks for email address.
205+
* `smsAndEmail` asks for both phone number and email address.
206+
*/
207+
type: 'push' | 'category' | 'sms' | 'email' | 'smsAndEmail';
208+
}[];
209+
};
210+
};
211+
welcomeNotification?: {
212+
/**
213+
* Disables sending a welcome notification to new site visitors. If you want to disable welcome notifications, this is the only option you need.
214+
*/
215+
disabled?: boolean;
216+
217+
/**
218+
* The welcome notification's message. You can localize this to your own language.
219+
* If left blank or set to blank, the default of 'Thanks for subscribing!' will be used.
220+
*/
221+
message: string;
222+
223+
/**
224+
* The welcome notification's title. You can localize this to your own language. If not set, or left blank, the site's title will be used.
225+
* Set to one space ' ' to clear the title, although this is not recommended.
226+
*/
227+
title?: string;
228+
229+
/**
230+
* By default, clicking the welcome notification does not open any link.
231+
* This is recommended because the user has just visited your site and subscribed.
232+
*/
233+
url: string;
234+
};
235+
236+
/**
237+
* Will enable customization of the notify/subscription bell button.
238+
*/
239+
notifyButton?: {
240+
/**
241+
* A function you define that returns true to show the Subscription Bell, or false to hide it.
242+
* Typically used the hide the Subscription Bell after the user is subscribed.
243+
* This function is not re-evaluated on every state change; this function is only evaluated once when the Subscription Bell begins to show.
244+
*/
245+
displayPredicate?: () => boolean | Promise<boolean>;
246+
247+
/**
248+
* Enable the Subscription Bell. The Subscription Bell is otherwise disabled by default.
249+
*/
250+
enable?: boolean;
251+
252+
/** Specify CSS-valid pixel offsets using bottom, left, and right. */
253+
offset?: { bottom: string; left: string; right: string };
254+
255+
/**
256+
* If `true`, the Subscription Bell will display an icon that there is 1 unread message.
257+
* When hovering over the Subscription Bell, the user will see custom text set by message.prenotify.
258+
*/
259+
prenotify: boolean;
260+
261+
/** Either `bottom-left` or `bottom-right`. The Subscription Bell will be fixed at this location on your page. */
262+
position?: 'bottom-left' | 'bottom-right';
263+
264+
/** Set `false` to hide the 'Powered by OneSignal' text in the Subscription Bell dialog popup. */
265+
showCredit: boolean;
266+
267+
/**
268+
* The Subscription Bell will initially appear at one of these sizes, and then shrink down to size `small` after the user subscribes.
269+
*/
270+
size?: 'small' | 'medium' | 'large';
271+
272+
/** Customize the Subscription Bell text. */
273+
text: {
274+
'dialog.blocked.message': string;
275+
'dialog.blocked.title': string;
276+
'dialog.main.button.subscribe': string;
277+
'dialog.main.button.unsubscribe': string;
278+
'dialog.main.title': string;
279+
'message.action.resubscribed': string;
280+
'message.action.subscribed': string;
281+
'message.action.subscribing': string;
282+
'message.action.unsubscribed': string;
283+
'message.prenotify': string;
284+
'tip.state.blocked': string;
285+
'tip.state.subscribed': string;
286+
'tip.state.unsubscribed': string;
287+
};
288+
};
289+
135290
persistNotification?: boolean;
136-
webhooks?: object;
291+
webhooks?: {
292+
/**
293+
* Enable this setting only if your server has CORS enabled and supports non-simple CORS requests.
294+
* If this setting is disabled, your webhook will not need CORS to receive data, but it will not receive the custom headers.
295+
* The simplest option is to leave it disabled.
296+
* @default false
297+
*/
298+
cors: boolean;
299+
300+
/**
301+
* This event occurs after a notification is clicked.
302+
* @example https://site.com/hook
303+
*/
304+
'notification.clicked'?: string;
305+
306+
/**
307+
* This event occurs after a notification is intentionally dismissed by the user (clicking the notification body or one of the notification action buttons does not trigger the dismissed webhook),
308+
* after a group of notifications are all dismissed (with this notification as part of that group), or after a notification expires on its own time and disappears. This event is supported on Chrome only.
309+
* @example https://site.com/hook
310+
*/
311+
'notification.dismissed'?: string;
312+
313+
/**
314+
* This event occurs after a notification is displayed.
315+
* @example https://site.com/hook
316+
*/
317+
'notification.willDisplay'?: string;
318+
};
137319
autoResubscribe?: boolean;
138320
autoRegister?: boolean;
139321
notificationClickHandlerMatch?: string;

src/snippets/InitObject.ts

Lines changed: 186 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,193 @@ export interface IInitObject {
22
appId: string;
33
subdomainName?: string;
44
requiresUserPrivacyConsent?: boolean;
5-
promptOptions?: object;
6-
welcomeNotification?: object;
7-
notifyButton?: object;
5+
promptOptions?: {
6+
slidedown: {
7+
prompts: {
8+
/**
9+
* Whether to automatically display the prompt.
10+
* `true` will display the prompt based on the delay options.
11+
* `false` will prevent the prompt from displaying until the Slidedowns methods are used.
12+
*/
13+
autoPrompt: boolean;
14+
15+
/**
16+
* Only available for type: category. Up to 10 categories.
17+
* @example
18+
* categories: [{ tag: 'local_news', label: 'Local News' }] // The user will be tagged with local_news but will see "Local News" in the prompt.
19+
*/
20+
categories: {
21+
/** Should identify the action. */
22+
tag: string;
23+
24+
/** What the user will see. */
25+
label: string;
26+
}[];
27+
28+
/**
29+
* The delay options for the prompt.
30+
* @example delay: { pageViews: 3, timeDelay: 20 } // The user will not be shown the prompt until 20 seconds after the 3rd page view.
31+
*/
32+
delay: {
33+
/** The number of pages a user needs to visit before the prompt is displayed. */
34+
pageViews?: number;
35+
36+
/** The number of seconds a user needs to wait before the prompt is displayed.Both options must be satisfied for the prompt to display */
37+
timeDelay?: number;
38+
};
39+
40+
/**
41+
* The text to display in the prompt.
42+
*/
43+
text?: {
44+
/** The callout asking the user to opt-in. Up to 90 characters. */
45+
actionMessage?: string;
46+
47+
/** Triggers the opt-in. Up to 15 characters. */
48+
acceptButton?: string;
49+
50+
/** Cancels opt-in. Up to 15 characters. */
51+
cancelMessage?: string;
52+
53+
/** The message of the confirmation prompt displayed after the email and/or phone number is provided. Up to 90 characters. */
54+
confirmMessage?: string;
55+
56+
/** Identifies the email text field. Up to 15 characters. */
57+
emailLabel?: string;
58+
59+
/** Cancels the category update. Up to 15 characters. */
60+
negativeUpdateButton?: string;
61+
62+
/** Saves the updated category tags. Up to 15 characters. */
63+
positiveUpdateButton?: string;
64+
65+
/** Identifies the phone number text field. Up to 15 characters. */
66+
smsLabel?: string;
67+
68+
/** A different message shown to subscribers presented the prompt again to update categories. Up to 90 characters. */
69+
updateMessage?: string;
70+
};
71+
72+
/**
73+
* The type of prompt to display.
74+
* `push` which is the Slide Prompt without categories.
75+
* `category` which is the Slide Prompt with categories.
76+
* `sms` only asks for phone number.
77+
* `email` only asks for email address.
78+
* `smsAndEmail` asks for both phone number and email address.
79+
*/
80+
type: 'push' | 'category' | 'sms' | 'email' | 'smsAndEmail';
81+
}[];
82+
};
83+
};
84+
welcomeNotification?: {
85+
/**
86+
* Disables sending a welcome notification to new site visitors. If you want to disable welcome notifications, this is the only option you need.
87+
*/
88+
disabled?: boolean;
89+
90+
/**
91+
* The welcome notification's message. You can localize this to your own language.
92+
* If left blank or set to blank, the default of 'Thanks for subscribing!' will be used.
93+
*/
94+
message: string;
95+
96+
/**
97+
* The welcome notification's title. You can localize this to your own language. If not set, or left blank, the site's title will be used.
98+
* Set to one space ' ' to clear the title, although this is not recommended.
99+
*/
100+
title?: string;
101+
102+
/**
103+
* By default, clicking the welcome notification does not open any link.
104+
* This is recommended because the user has just visited your site and subscribed.
105+
*/
106+
url: string;
107+
};
108+
109+
/**
110+
* Will enable customization of the notify/subscription bell button.
111+
*/
112+
notifyButton?: {
113+
/**
114+
* A function you define that returns true to show the Subscription Bell, or false to hide it.
115+
* Typically used the hide the Subscription Bell after the user is subscribed.
116+
* This function is not re-evaluated on every state change; this function is only evaluated once when the Subscription Bell begins to show.
117+
*/
118+
displayPredicate?: () => boolean | Promise<boolean>;
119+
120+
/**
121+
* Enable the Subscription Bell. The Subscription Bell is otherwise disabled by default.
122+
*/
123+
enable?: boolean;
124+
125+
/** Specify CSS-valid pixel offsets using bottom, left, and right. */
126+
offset?: { bottom: string; left: string; right: string };
127+
128+
/**
129+
* If `true`, the Subscription Bell will display an icon that there is 1 unread message.
130+
* When hovering over the Subscription Bell, the user will see custom text set by message.prenotify.
131+
*/
132+
prenotify: boolean;
133+
134+
/** Either `bottom-left` or `bottom-right`. The Subscription Bell will be fixed at this location on your page. */
135+
position?: 'bottom-left' | 'bottom-right';
136+
137+
/** Set `false` to hide the 'Powered by OneSignal' text in the Subscription Bell dialog popup. */
138+
showCredit: boolean;
139+
140+
/**
141+
* The Subscription Bell will initially appear at one of these sizes, and then shrink down to size `small` after the user subscribes.
142+
*/
143+
size?: 'small' | 'medium' | 'large';
144+
145+
/** Customize the Subscription Bell text. */
146+
text: {
147+
'dialog.blocked.message': string;
148+
'dialog.blocked.title': string;
149+
'dialog.main.button.subscribe': string;
150+
'dialog.main.button.unsubscribe': string;
151+
'dialog.main.title': string;
152+
'message.action.resubscribed': string;
153+
'message.action.subscribed': string;
154+
'message.action.subscribing': string;
155+
'message.action.unsubscribed': string;
156+
'message.prenotify': string;
157+
'tip.state.blocked': string;
158+
'tip.state.subscribed': string;
159+
'tip.state.unsubscribed': string;
160+
};
161+
};
162+
8163
persistNotification?: boolean;
9-
webhooks?: object;
164+
webhooks?: {
165+
/**
166+
* Enable this setting only if your server has CORS enabled and supports non-simple CORS requests.
167+
* If this setting is disabled, your webhook will not need CORS to receive data, but it will not receive the custom headers.
168+
* The simplest option is to leave it disabled.
169+
* @default false
170+
*/
171+
cors: boolean;
172+
173+
/**
174+
* This event occurs after a notification is clicked.
175+
* @example https://site.com/hook
176+
*/
177+
'notification.clicked'?: string;
178+
179+
/**
180+
* This event occurs after a notification is intentionally dismissed by the user (clicking the notification body or one of the notification action buttons does not trigger the dismissed webhook),
181+
* after a group of notifications are all dismissed (with this notification as part of that group), or after a notification expires on its own time and disappears. This event is supported on Chrome only.
182+
* @example https://site.com/hook
183+
*/
184+
'notification.dismissed'?: string;
185+
186+
/**
187+
* This event occurs after a notification is displayed.
188+
* @example https://site.com/hook
189+
*/
190+
'notification.willDisplay'?: string;
191+
};
10192
autoResubscribe?: boolean;
11193
autoRegister?: boolean;
12194
notificationClickHandlerMatch?: string;

0 commit comments

Comments
 (0)