11/* *
2- * Modified MIT License
3- *
4- * Copyright 2017 OneSignal
5- *
6- * Permission is hereby granted, free of charge, to any person obtaining a copy
7- * of this software and associated documentation files (the "Software"), to deal
8- * in the Software without restriction, including without limitation the rights
9- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10- * copies of the Software, and to permit persons to whom the Software is
11- * furnished to do so, subject to the following conditions:
12- *
13- * 1. The above copyright notice and this permission notice shall be included in
14- * all copies or substantial portions of the Software.
15- *
16- * 2. All copies of substantial portions of the Software may only be used in connection
17- * with services provided by OneSignal.
18- *
19- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25- * THE SOFTWARE.
2+ Modified MIT License
3+
4+ Copyright 2017 OneSignal
5+
6+ Permission is hereby granted, free of charge, to any person obtaining a copy
7+ of this software and associated documentation files (the "Software"), to deal
8+ in the Software without restriction, including without limitation the rights
9+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+ copies of the Software, and to permit persons to whom the Software is
11+ furnished to do so, subject to the following conditions:
12+
13+ 1. The above copyright notice and this permission notice shall be included in
14+ all copies or substantial portions of the Software.
15+
16+ 2. All copies of substantial portions of the Software may only be used in connection
17+ with services provided by OneSignal.
18+
19+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25+ THE SOFTWARE.
2626 */
2727
28- /* **
29-
28+ /* *
3029 ### Setting up the SDK ###
3130 Follow the documentation from https://documentation.onesignal.com/docs/ios-sdk-setupto setup OneSignal in your app.
3231
4039
4140 ### More ###
4241 iOS Push Cert: https://documentation.onesignal.com/docs/generating-an-ios-push-certificate
43-
44- ***/
42+ */
4543
4644#import < Foundation/Foundation.h>
4745#import < UserNotifications/UserNotifications.h>
@@ -68,27 +66,6 @@ typedef NS_ENUM(NSUInteger, OSNotificationDisplayType) {
6866 OSNotificationDisplayTypeNotification
6967};
7068
71- @interface OSInAppMessageAction : NSObject
72-
73- // The action name attached to the IAM action
74- @property (strong , nonatomic , nullable ) NSString *clickName;
75-
76- // The URL (if any) that should be opened when the action occurs
77- @property (strong , nonatomic , nullable ) NSURL *clickUrl;
78-
79- // Whether or not the click action is first click on the IAM
80- @property (nonatomic ) BOOL firstClick;
81-
82- // Whether or not the click action dismisses the message
83- @property (nonatomic ) BOOL closesMessage;
84-
85- @end
86-
87- @protocol OSInAppMessageDelegate <NSObject >
88- @optional
89- - (void )handleMessageAction : (OSInAppMessageAction * _Nonnull)action NS_SWIFT_NAME(handleMessageAction(action:));
90- @end
91-
9269@interface OSNotificationAction : NSObject
9370
9471/* The type of the notification action */
@@ -99,9 +76,7 @@ typedef NS_ENUM(NSUInteger, OSNotificationDisplayType) {
9976
10077@end
10178
102-
103- // #### Notification Payload Received Object
104-
79+ /* Notification Payload Received Object */
10580@interface OSNotificationPayload : NSObject
10681
10782/* Unique Message Identifier */
@@ -174,7 +149,7 @@ typedef NS_ENUM(NSUInteger, OSNotificationDisplayType) {
174149
175150@end
176151
177- // ## OneSignal OSNotification
152+ /* OneSignal OSNotification */
178153@interface OSNotification : NSObject
179154
180155/* Notification Payload */
@@ -204,7 +179,6 @@ typedef NS_ENUM(NSUInteger, OSNotificationDisplayType) {
204179
205180@end
206181
207-
208182@interface OSNotificationOpenedResult : NSObject
209183
210184@property (readonly )OSNotification* notification;
@@ -215,6 +189,54 @@ typedef NS_ENUM(NSUInteger, OSNotificationDisplayType) {
215189
216190@end ;
217191
192+ @interface OSInAppMessageAction : NSObject
193+
194+ /* The action name attached to the IAM action */
195+ @property (strong , nonatomic , nullable ) NSString *clickName;
196+
197+ /* The URL (if any) that should be opened when the action occurs */
198+ @property (strong , nonatomic , nullable ) NSURL *clickUrl;
199+
200+ /* Whether or not the click action is first click on the IAM */
201+ @property (nonatomic ) BOOL firstClick;
202+
203+ /* Whether or not the click action dismisses the message */
204+ @property (nonatomic ) BOOL closesMessage;
205+
206+ @end
207+
208+ @protocol OSInAppMessageDelegate <NSObject >
209+ @optional
210+ - (void )handleMessageAction : (OSInAppMessageAction * _Nonnull)action NS_SWIFT_NAME(handleMessageAction(action:));
211+ @end
212+
213+ /* OneSignal Session Types */
214+ typedef NS_ENUM (NSUInteger , Session) {
215+ DIRECT,
216+ INDIRECT,
217+ UNATTRIBUTED,
218+ DISABLED
219+ };
220+
221+ @interface OSOutcomeEvent : NSObject
222+
223+ // Session enum (DIRECT, INDIRECT, UNATTRIBUTED, or DISABLED) to determine code route and request params
224+ @property (nonatomic ) Session session;
225+
226+ // Notification ids for the current session
227+ @property (strong , nonatomic , nullable ) NSArray *notificationIds;
228+
229+ // Id or name of the event
230+ @property (strong , nonatomic , nonnull ) NSString *name;
231+
232+ // Time of the event occurring
233+ @property (strong , nonatomic , nonnull ) NSNumber *timestamp;
234+
235+ // A weight to attach to the outcome name
236+ @property (strong , nonatomic , nonnull ) NSDecimalNumber *weight;
237+
238+ @end
239+
218240
219241typedef NS_ENUM (NSInteger , OSNotificationPermission) {
220242 // The user has not yet made a choice regarding whether your app can show notifications.
@@ -308,6 +330,7 @@ typedef NS_ENUM(NSInteger, OSNotificationPermission) {
308330
309331typedef void (^OSWebOpenURLResultBlock)(BOOL shouldOpen);
310332
333+ /* Block for generic results on success and errors on failure*/
311334typedef void (^OSResultSuccessBlock)(NSDictionary * result);
312335typedef void (^OSFailureBlock)(NSError * error);
313336
@@ -323,6 +346,10 @@ typedef void (^OSHandleNotificationActionBlock)(OSNotificationOpenedResult * res
323346/* Block for handling user click on an in app message*/
324347typedef void (^OSHandleInAppMessageActionClickBlock)(OSInAppMessageAction* action);
325348
349+ /* Block for handling outcome event being sent successfully*/
350+ typedef void (^OSSendOutcomeSuccess)(OSOutcomeEvent* outcome);
351+
352+
326353/* Dictionary of keys to pass alongside the init settings*/
327354
328355/* Let OneSignal directly prompt for push notifications on init*/
@@ -350,8 +377,6 @@ extern NSString * const kOSSettingsKeyInFocusDisplayOption;
350377*/
351378extern NSString * const kOSSettingsKeyProvidesAppNotificationSettings ;
352379
353-
354-
355380// ======= OneSignal Class Interface =========
356381@interface OneSignal : NSObject
357382
@@ -362,10 +387,10 @@ typedef NS_ENUM(NSUInteger, ONE_S_LOG_LEVEL) {
362387};
363388
364389
365- /* *
390+ /*
366391 Initialize OneSignal.
367392 Sends push token to OneSignal so you can later send notifications.
368- */
393+ */
369394
370395// - Initialization
371396+ (id )initWithLaunchOptions : (NSDictionary *)launchOptions appId : (NSString *)appId ;
@@ -396,7 +421,7 @@ typedef NS_ENUM(NSUInteger, ONE_S_LOG_LEVEL) {
396421
397422// - Logging
398423+ (void )setLogLevel : (ONE_S_LOG_LEVEL)logLevel visualLevel : (ONE_S_LOG_LEVEL)visualLogLevel ;
399- + (void ) onesignal_Log : (ONE_S_LOG_LEVEL)logLevel message : (NSString *)message ;
424+ + (void )onesignal_Log : (ONE_S_LOG_LEVEL)logLevel message : (NSString *)message ;
400425
401426// - Tagging
402427+ (void )sendTag : (NSString *)key value : (NSString *)value onSuccess : (OSResultSuccessBlock)successBlock onFailure : (OSFailureBlock)failureBlock ;
@@ -466,30 +491,37 @@ typedef void (^OSEmailSuccessBlock)();
466491// Email Auth Token is a (recommended) optional parameter that should *NOT* be generated on the client.
467492// For security purposes, the emailAuthToken should be generated by your backend server.
468493// If you do not have a backend server for your application, use the version of thge setEmail: method without an emailAuthToken parameter.
494+ + (void )setEmail : (NSString * _Nonnull)email withEmailAuthHashToken : (NSString * _Nullable)hashToken ;
469495+ (void )setEmail : (NSString * _Nonnull)email withEmailAuthHashToken : (NSString * _Nullable)hashToken withSuccess : (OSEmailSuccessBlock _Nullable)successBlock withFailure : (OSEmailFailureBlock _Nullable)failureBlock ;
470496
471497// Sets email without an authentication token
498+ + (void )setEmail : (NSString * _Nonnull)email ;
472499+ (void )setEmail : (NSString * _Nonnull)email withSuccess : (OSEmailSuccessBlock _Nullable)successBlock withFailure : (OSEmailFailureBlock _Nullable)failureBlock ;
473500
474501// Logs the device out of the current email.
502+ + (void )logoutEmail ;
475503+ (void )logoutEmailWithSuccess : (OSEmailSuccessBlock _Nullable)successBlock withFailure : (OSEmailFailureBlock _Nullable)failureBlock ;
476504
477- // convenience - no completion blocks
478- + (void )logoutEmail ;
479- + (void )setEmail : (NSString * _Nonnull)email ;
480- + (void )setEmail : (NSString * _Nonnull)email withEmailAuthHashToken : (NSString * _Nullable)hashToken ;
481505
482- // In App Messaging Trigger methods
506+ // External user id
507+ + (void )setExternalUserId : (NSString * _Nonnull)externalId ;
508+ + (void )removeExternalUserId ;
509+
510+ // In-App Messaging triggers
483511+ (void )addTrigger : (NSString * _Nonnull)key withValue : (id _Nonnull)value ;
484512+ (void )addTriggers : (NSDictionary <NSString *, id> * _Nonnull)triggers ;
485513+ (void )removeTriggerForKey : (NSString * _Nonnull)key ;
486514+ (void )removeTriggersForKeys : (NSArray <NSString *> * _Nonnull)keys ;
487515+ (NSDictionary <NSString *, id> * _Nonnull)getTriggers ;
488516+ (id _Nullable)getTriggerValueForKey : (NSString * _Nonnull)key ;
489517
490- + (void )setExternalUserId : (NSString * _Nonnull)externalId ;
491- + (void )removeExternalUserId ;
492-
518+ // Outcome Events
519+ + (void )sendOutcome : (NSString * _Nonnull)name ;
520+ + (void )sendOutcome : (NSString * _Nonnull)name onSuccess : (OSSendOutcomeSuccess _Nullable)success ;
521+ + (void )sendUniqueOutcome : (NSString * _Nonnull)name ;
522+ + (void )sendUniqueOutcome : (NSString * _Nonnull)name onSuccess : (OSSendOutcomeSuccess _Nullable)success ;
523+ + (void )sendOutcomeWithValue : (NSString * _Nonnull)name value : (NSNumber * _Nonnull)value ;
524+ + (void )sendOutcomeWithValue : (NSString * _Nonnull)name value : (NSNumber * _Nonnull)value onSuccess : (OSSendOutcomeSuccess _Nullable)success ;
493525@end
494526
495527#pragma clang diagnostic pop
0 commit comments