Skip to content
This repository was archived by the owner on Jul 22, 2020. It is now read-only.

Commit 32af84d

Browse files
committed
Prepare for 5.0.0
1 parent efe72a3 commit 32af84d

File tree

9 files changed

+389
-150
lines changed

9 files changed

+389
-150
lines changed

Artifacts/include/Iterable-iOS-SDK/IterableAPI.h

Lines changed: 82 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66
// Copyright (c) 2014 Iterable. All rights reserved.
77
//
88

9-
@import Foundation;
9+
#import <UIKit/UIKit.h>
1010
#import "CommerceItem.h"
11+
#import "IterableAction.h"
1112
#import "IterableConstants.h"
13+
#import "IterableConfig.h"
14+
#import "IterableAttributionInfo.h"
1215

1316
// all params are nonnull, unless annotated otherwise
1417
NS_ASSUME_NONNULL_BEGIN
@@ -23,16 +26,6 @@ typedef void (^OnSuccessHandler)(NSDictionary *data);
2326
*/
2427
typedef void (^OnFailureHandler)(NSString *reason, NSData *_Nullable data);
2528

26-
/**
27-
Enum representing push platform; apple push notification service, production vs sandbox
28-
*/
29-
typedef NS_ENUM(NSInteger, PushServicePlatform) {
30-
/** The sandbox push service */
31-
APNS_SANDBOX,
32-
/** The production push service */
33-
APNS
34-
};
35-
3629
/**
3730
`IterableAPI` contains all the essential functions for communicating with Iterable's API
3831
*/
@@ -42,6 +35,11 @@ typedef NS_ENUM(NSInteger, PushServicePlatform) {
4235
/// @name Properties
4336
////////////////////
4437

38+
/**
39+
SDK Configuration object
40+
*/
41+
@property(nonatomic, readonly) IterableConfig *config;
42+
4543
/**
4644
The apiKey that this IterableAPI is using
4745
*/
@@ -57,167 +55,92 @@ typedef NS_ENUM(NSInteger, PushServicePlatform) {
5755
*/
5856
@property(nonatomic, readonly, copy) NSString *userId;
5957

60-
6158
/**
6259
The hex representation of this device token
6360
*/
6461
@property(nonatomic, readonly, copy) NSString *hexToken;
6562

66-
/////////////////////////////////
67-
/// @name Creating an IterableAPI
68-
/////////////////////////////////
69-
70-
/*!
71-
@method
72-
73-
@abstract Initializes Iterable with launchOptions
74-
75-
@param apiKey your Iterable apiKey
76-
@param email the email of the user logged in
77-
@param launchOptions launchOptions from application:didFinishLaunchingWithOptions or custom launchOptions
78-
@param useCustomLaunchOptions whether or not to use the custom launchOption without the UIApplicationLaunchOptionsRemoteNotificationKey
79-
80-
@return an instance of IterableAPI
63+
/**
64+
The userInfo dictionary which came with last push.
8165
*/
82-
- (instancetype) initWithApiKey:(NSString *)apiKey andEmail:(NSString *)email launchOptions:(nullable NSDictionary *)launchOptions useCustomLaunchOptions:(BOOL)useCustomLaunchOptions;
83-
84-
/*!
85-
@method
86-
87-
@abstract Initializes Iterable with just an API key and email, but no launchOptions
88-
89-
@param apiKey your Iterable apiKey
90-
@param userId the userId of the user logged in
91-
92-
@return an instance of IterableAPI
66+
@property(nonatomic, readonly, copy, nullable) NSDictionary *lastPushPayload;
67+
/**
68+
Attribution info (campaignId, messageId etc.) for last push open or app link click from an email.
9369
*/
94-
- (instancetype) initWithApiKey:(NSString *)apiKey andUserId:(NSString *) userId;
70+
@property(nonatomic, readwrite, strong, nullable) IterableAttributionInfo *attributionInfo;
9571

96-
/*!
97-
@method
98-
99-
@abstract Initializes Iterable with launchOptions
100-
101-
@param apiKey your Iterable apiKey
102-
@param userId the userId of the user logged in
103-
@param launchOptions launchOptions from application:didFinishLaunchingWithOptions
104-
105-
@return an instance of IterableAPI
106-
*/
107-
- (instancetype) initWithApiKey:(NSString *)apiKey andUserId:(NSString *)userId launchOptions:(nullable NSDictionary *)launchOptions;
72+
/////////////////////////////////
73+
/// @name Initializing IterableAPI
74+
/////////////////////////////////
10875

109-
/*!
110-
@method
111-
112-
@abstract Initializes Iterable with launchOptions
113-
114-
@param apiKey your Iterable apiKey
115-
@param userId the userId of the user logged in
116-
@param launchOptions launchOptions from application:didFinishLaunchingWithOptions or custom launchOptions
117-
@param useCustomLaunchOptions whether or not to use the custom launchOption without the UIApplicationLaunchOptionsRemoteNotificationKey
118-
119-
@return an instance of IterableAPI
76+
/**
77+
* Initializes IterableAPI
78+
* This method must be called from UIApplicationDelegate's `application:didFinishLaunchingWithOptions:`
79+
*
80+
* @note Make sure you also call `setEmail:` or `setUserId:` before making any API calls
81+
* @param apiKey Iterable Mobile API key
82+
* @param launchOptions launchOptions object passed from `application:didFinishLaunchingWithOptions:`
12083
*/
121-
- (instancetype) initWithApiKey:(NSString *)apiKey andUserId:(NSString *)userId launchOptions:(nullable NSDictionary *)launchOptions useCustomLaunchOptions:(BOOL)useCustomLaunchOptions;
84+
+ (void)initializeWithApiKey:(NSString *)apiKey launchOptions:(nullable NSDictionary *)launchOptions;
12285

123-
/*!
124-
@method
125-
126-
@abstract Initializes a shared instance of Iterable with launchOptions
127-
128-
@discussion The sharedInstanceWithApiKey with email is preferred over userId.
129-
This method will set up a singleton instance of the `IterableAPI` class for
130-
you using the given project API key. When you want to make calls to Iterable
131-
elsewhere in your code, you can use `sharedInstance`. If launchOptions is there and
132-
the app was launched from a remote push notification, we will track a pushOpen.
133-
134-
@param apiKey your Iterable apiKey
135-
@param userId the userId of the user logged in
136-
@param launchOptions launchOptions from application:didFinishLaunchingWithOptions
137-
138-
@return an instance of IterableAPI
86+
/**
87+
* Initializes IterableAPI
88+
* This method must be called from UIApplicationDelegate's `application:didFinishLaunchingWithOptions:`
89+
*
90+
* @note Make sure you also call `setEmail:` or `setUserId:` before making any API calls
91+
* @param apiKey Iterable Mobile API key
92+
* @param launchOptions launchOptions object passed from `application:didFinishLaunchingWithOptions:`
93+
* @param config `IterableConfig` object holding SDK configuration options
13994
*/
140-
+ (IterableAPI *) sharedInstanceWithApiKey:(NSString *)apiKey andUserId:(NSString *)userId launchOptions:(nullable NSDictionary *)launchOptions;
95+
+ (void)initializeWithApiKey:(NSString *)apiKey launchOptions:(nullable NSDictionary *)launchOptions config:(IterableConfig *)config;
14196

142-
/*!
143-
@method
144-
145-
@abstract Initializes a shared instance of Iterable with launchOptions
146-
147-
@discussion The sharedInstanceWithApiKey with email is preferred over userId.
148-
This method will set up a singleton instance of the `IterableAPI` class for
149-
you using the given project API key. When you want to make calls to Iterable
150-
elsewhere in your code, you can use `sharedInstance`. If launchOptions is there and
151-
the app was launched from a remote push notification, we will track a pushOpen.
152-
153-
@param apiKey your Iterable apiKey
154-
@param email the email of the user logged in
155-
@param launchOptions launchOptions from application:didFinishLaunchingWithOptions
156-
157-
@return an instance of IterableAPI
158-
*/
159-
+ (IterableAPI *) sharedInstanceWithApiKey:(NSString *)apiKey andEmail:(NSString *)email launchOptions:(nullable NSDictionary *)launchOptions;
97+
/////////////////////////////
98+
/// @name Setting user email or user id
99+
/////////////////////////////
160100

161-
/*!
162-
@method
163-
164-
@abstract Get the previously instantiated singleton instance of the API
165-
166-
@discussion Must be initialized with `sharedInstanceWithApiKey:` before
167-
calling this class method.
168-
169-
@return the existing `IterableAPI` instance
170-
171-
@warning `sharedInstance` will return `nil` if called before calling `sharedInstanceWithApiKey:andEmail:launchOptions:`
101+
/**
102+
* Set user email used for API calls
103+
* Calling this or `setUserId:` is required before making any API calls.
104+
*
105+
* @note This clears userId and persists the user email so you only need to call this once when the user logs in.
106+
* @param email User email
172107
*/
173-
+ (nullable IterableAPI *)sharedInstance;
108+
- (void)setEmail:(nullable NSString *)email;
174109

175-
/*!
176-
@method
177-
178-
@abstract Sets the previously instantiated singleton instance of the API to nil
179-
110+
/**
111+
* Set user ID used for API calls
112+
* Calling this or `setEmail:` is required before making any API calls.
113+
*
114+
* @note This clears user email and persists the user ID so you only need to call this once when the user logs in.
115+
* @param userId User ID
180116
*/
181-
+ (void)clearSharedInstance;
117+
- (void)setUserId:(nullable NSString *)userId;
182118

183119
/////////////////////////////
184120
/// @name Registering a token
185121
/////////////////////////////
186122

187-
/*!
188-
@method
189-
190-
@abstract Register this device's token with Iterable
191-
192-
@param token The token representing this device/application pair, obtained from
123+
/**
124+
* Register this device's token with Iterable
125+
* Push integration name and platform are read from `IterableConfig`. If platform is set to `AUTO`, it will
126+
* read APNS environment from the provisioning profile and use an integration name specified in `IterableConfig`.
127+
* @param token The token representing this device/application pair, obtained from
193128
`application:didRegisterForRemoteNotificationsWithDeviceToken`
194129
after registering for remote notifications
195-
@param appName The application name, as configured in Iterable during set up of the push integration
196-
@param pushServicePlatform The PushServicePlatform to use for this device; dictates whether to register this token in the sandbox or production environment
197-
198-
@see PushServicePlatform
199-
200130
*/
201-
- (void)registerToken:(NSData *)token appName:(NSString *)appName pushServicePlatform:(PushServicePlatform)pushServicePlatform;
131+
- (void)registerToken:(NSData *)token;
202132

203-
/*!
204-
@method
205-
206-
@abstract Register this device's token with Iterable with custom completion blocks
207-
208-
@param token The token representing this device/application pair, obtained from
209-
`application:didRegisterForRemoteNotificationsWithDeviceToken`
210-
after registering for remote notifications
211-
@param appName The application name, as configured in Iterable during set up of the push integration
212-
@param pushServicePlatform The PushServicePlatform to use for this device; dictates whether to register this token in the sandbox or production environment
213-
@param onSuccess OnSuccessHandler to invoke if token registration is successful
214-
@param onFailure OnFailureHandler to invoke if token registration fails
215-
216-
@see PushServicePlatform
217-
@see OnSuccessHandler
218-
@see OnFailureHandler
133+
/**
134+
* Register this device's token with Iterable
135+
* Push integration name and platform are read from `IterableConfig`. If platform is set to `AUTO`, it will
136+
* read APNS environment from the provisioning profile and use an integration name specified in `IterableConfig`.
137+
* @param token The token representing this device/application pair, obtained from
138+
`application:didRegisterForRemoteNotificationsWithDeviceToken`
139+
after registering for remote notifications
140+
* @param onSuccess OnSuccessHandler to invoke if token registration is successful
141+
* @param onFailure OnFailureHandler to invoke if token registration fails
219142
*/
220-
- (void)registerToken:(NSData *)token appName:(NSString *)appName pushServicePlatform:(PushServicePlatform)pushServicePlatform onSuccess:(OnSuccessHandler)onSuccess onFailure:(OnFailureHandler)onFailure;
143+
- (void)registerToken:(NSData *)token onSuccess:(OnSuccessHandler)onSuccess onFailure:(OnFailureHandler)onFailure;
221144

222145
/////////////////////////////
223146
/// @name Disabling a device
@@ -590,8 +513,21 @@ typedef NS_ENUM(NSInteger, PushServicePlatform) {
590513
591514
@discussion passes the string of the redirected URL to the callback, returns the original webpageURL if not an iterable link
592515
*/
593-
+(void) getAndTrackDeeplink:(NSURL *)webpageURL callbackBlock:(ITEActionBlock)callbackBlock;
516+
+ (void)getAndTrackDeeplink:(NSURL *)webpageURL callbackBlock:(ITEActionBlock)callbackBlock;
517+
518+
/**
519+
* Handles a Universal Link
520+
* For Iterable links, it will track the click and retrieve the original URL,
521+
* pass it to `IterableURLDelegate` for handling
522+
* If it's not an Iterable link, it just passes the same URL to `IterableURLDelegate`
523+
*
524+
* @param url the URL obtained from `[NSUserActivity webpageURL]`
525+
* @return YES if it is an Iterable link, or the value returned from `IterableURLDelegate` otherwise
526+
*/
527+
+ (BOOL)handleUniversalLink:(NSURL *)url;
594528

595529
@end
596530

597531
NS_ASSUME_NONNULL_END
532+
533+
#import "IterableAPI+Deprecated.h"
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
//
2+
// IterableAction.h
3+
// Iterable-iOS-SDK
4+
//
5+
// Created by Victor Babenko on 5/1/18.
6+
// Copyright © 2018 Iterable. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
11+
NS_ASSUME_NONNULL_BEGIN
12+
13+
/** Open the URL or deep link */
14+
extern NSString *const IterableActionTypeOpenUrl;
15+
16+
/**
17+
`IterableAction` represents an action defined as a response to user events.
18+
It is currently used in push notification actions (open push & action buttons).
19+
*/
20+
@interface IterableAction : NSObject
21+
22+
////////////////////
23+
/// @name Properties
24+
////////////////////
25+
26+
/**
27+
* Action type
28+
*
29+
* If `IterableActionTypeOpenUrl`, the SDK will call `IterableURLDelegate` and then try to open the URL if
30+
* the delegate returned NO or was not set.
31+
*
32+
* For other types, `IterableCustomActionDelegate` will be called.
33+
*/
34+
@property(nonatomic, readonly) NSString *type;
35+
36+
/**
37+
* Additional data, its content depends on the action type
38+
*/
39+
@property(nonatomic, readonly) NSString *data;
40+
41+
////////////////////
42+
/// @name Optional Fields
43+
////////////////////
44+
45+
/** The text response typed by the user */
46+
@property(nonatomic, readwrite) NSString *userInput;
47+
48+
////////////////////
49+
/// @name Creating IterableAction
50+
////////////////////
51+
52+
/**
53+
* Creates a new `IterableAction` from a dictionary
54+
* @param dictionary Dictionary containing action data
55+
* @return `IterableAction` instance
56+
*/
57+
+ (instancetype)actionFromDictionary:(NSDictionary *)dictionary;
58+
59+
/**
60+
* Creates a new `IterableAction` with type `IterableActionTypeOpenUrl`
61+
* and the specified URL
62+
* @param url URL to open
63+
* @return `IterableAction` instance
64+
*/
65+
+ (instancetype)actionOpenUrl:(NSString *)url;
66+
67+
////////////////////
68+
/// @name Methods
69+
////////////////////
70+
71+
/**
72+
* Checks whether this action is of a specific type
73+
* @param type Action type to match against
74+
* @return Boolean indicating whether the action type matches the one passed to this method
75+
*/
76+
- (BOOL)isOfType:(NSString *)type;
77+
78+
@end
79+
80+
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)