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,57 @@ 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+ //  Convert the object into a NSDictionary
239+ - (NSDictionary  * _Nonnull)jsonRepresentation ;
240+ 
241+ @end 
242+ 
218243
219244typedef  NS_ENUM (NSInteger , OSNotificationPermission) {
220245    //  The user has not yet made a choice regarding whether your app can show notifications.
@@ -308,6 +333,7 @@ typedef NS_ENUM(NSInteger, OSNotificationPermission) {
308333
309334typedef  void  (^OSWebOpenURLResultBlock)(BOOL  shouldOpen);
310335
336+ /* Block for generic results on success and errors on failure*/ 
311337typedef  void  (^OSResultSuccessBlock)(NSDictionary * result);
312338typedef  void  (^OSFailureBlock)(NSError * error);
313339
@@ -323,6 +349,10 @@ typedef void (^OSHandleNotificationActionBlock)(OSNotificationOpenedResult * res
323349/* Block for handling user click on an in app message*/ 
324350typedef  void  (^OSHandleInAppMessageActionClickBlock)(OSInAppMessageAction* action);
325351
352+ /* Block for handling outcome event being sent successfully*/ 
353+ typedef  void  (^OSSendOutcomeSuccess)(OSOutcomeEvent* outcome);
354+ 
355+ 
326356/* Dictionary of keys to pass alongside the init settings*/ 
327357
328358/* Let OneSignal directly prompt for push notifications on init*/ 
@@ -350,8 +380,6 @@ extern NSString * const kOSSettingsKeyInFocusDisplayOption;
350380*/ 
351381extern  NSString  * const  kOSSettingsKeyProvidesAppNotificationSettings ;
352382
353- 
354- 
355383// ======= OneSignal Class Interface ========= 
356384@interface  OneSignal  : NSObject 
357385
@@ -362,10 +390,10 @@ typedef NS_ENUM(NSUInteger, ONE_S_LOG_LEVEL) {
362390};
363391
364392
365- /* * 
393+ /* 
366394 Initialize OneSignal. 
367395 Sends push token to OneSignal so you can later send notifications. 
368- */ 
396+   */ 
369397
370398//  - Initialization
371399+ (id )initWithLaunchOptions : (NSDictionary *)launchOptions  appId : (NSString *)appId ;
@@ -396,7 +424,7 @@ typedef NS_ENUM(NSUInteger, ONE_S_LOG_LEVEL) {
396424
397425//  - Logging
398426+ (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 ;
427+ + (void )onesignal_Log : (ONE_S_LOG_LEVEL)logLevel  message : (NSString *)message ;
400428
401429//  - Tagging
402430+ (void )sendTag : (NSString *)key  value : (NSString *)value  onSuccess : (OSResultSuccessBlock)successBlock  onFailure : (OSFailureBlock)failureBlock ;
@@ -466,30 +494,37 @@ typedef void (^OSEmailSuccessBlock)();
466494//  Email Auth Token is a (recommended) optional parameter that should *NOT* be generated on the client.
467495//  For security purposes, the emailAuthToken should be generated by your backend server.
468496//  If you do not have a backend server for your application, use the version of thge setEmail: method without an emailAuthToken parameter.
497+ + (void )setEmail : (NSString  * _Nonnull)email  withEmailAuthHashToken : (NSString  * _Nullable)hashToken ;
469498+ (void )setEmail : (NSString  * _Nonnull)email  withEmailAuthHashToken : (NSString  * _Nullable)hashToken  withSuccess : (OSEmailSuccessBlock _Nullable)successBlock  withFailure : (OSEmailFailureBlock _Nullable)failureBlock ;
470499
471500//  Sets email without an authentication token
501+ + (void )setEmail : (NSString  * _Nonnull)email ;
472502+ (void )setEmail : (NSString  * _Nonnull)email  withSuccess : (OSEmailSuccessBlock _Nullable)successBlock  withFailure : (OSEmailFailureBlock _Nullable)failureBlock ;
473503
474504//  Logs the device out of the current email.
505+ + (void )logoutEmail ;
475506+ (void )logoutEmailWithSuccess : (OSEmailSuccessBlock _Nullable)successBlock  withFailure : (OSEmailFailureBlock _Nullable)failureBlock ;
476507
477- // convenience - no completion blocks
478- + (void )logoutEmail ;
479- + (void )setEmail : (NSString  * _Nonnull)email ;
480- + (void )setEmail : (NSString  * _Nonnull)email  withEmailAuthHashToken : (NSString  * _Nullable)hashToken ;
481508
482- //  In App Messaging Trigger methods
509+ //  External user id
510+ + (void )setExternalUserId : (NSString  * _Nonnull)externalId ;
511+ + (void )removeExternalUserId ;
512+ 
513+ //  In-App Messaging triggers
483514+ (void )addTrigger : (NSString  * _Nonnull)key  withValue : (id  _Nonnull)value ;
484515+ (void )addTriggers : (NSDictionary <NSString *, id> * _Nonnull)triggers ;
485516+ (void )removeTriggerForKey : (NSString  * _Nonnull)key ;
486517+ (void )removeTriggersForKeys : (NSArray <NSString *> * _Nonnull)keys ;
487518+ (NSDictionary <NSString *, id> * _Nonnull)getTriggers ;
488519+ (id  _Nullable)getTriggerValueForKey : (NSString  * _Nonnull)key ;
489520
490- + (void )setExternalUserId : (NSString  * _Nonnull)externalId ;
491- + (void )removeExternalUserId ;
492- 
521+ //  Outcome Events
522+ + (void )sendOutcome : (NSString  * _Nonnull)name ;
523+ + (void )sendOutcome : (NSString  * _Nonnull)name  onSuccess : (OSSendOutcomeSuccess _Nullable)success ;
524+ + (void )sendUniqueOutcome : (NSString  * _Nonnull)name ;
525+ + (void )sendUniqueOutcome : (NSString  * _Nonnull)name  onSuccess : (OSSendOutcomeSuccess _Nullable)success ;
526+ + (void )sendOutcomeWithValue : (NSString  * _Nonnull)name  value : (NSNumber  * _Nonnull)value ;
527+ + (void )sendOutcomeWithValue : (NSString  * _Nonnull)name  value : (NSNumber  * _Nonnull)value  onSuccess : (OSSendOutcomeSuccess _Nullable)success ;
493528@end 
494529
495530#pragma  clang diagnostic pop
0 commit comments