@@ -255,19 +255,39 @@ + (OnFailureHandler)defaultOnFailure:(NSString *)identifier
255255
256256 @abstract creates an iterable session with launchOptions
257257
258- @param launchOptions launchOptions from application:didFinishLaunchingWithOptions
258+ @param launchOptions launchOptions from application:didFinishLaunchingWithOptions
259259
260260 @return an instance of IterableAPI
261261 */
262262- (instancetype )createSession : (NSDictionary *)launchOptions
263+ {
264+ return [self createSession: launchOptions useCustomLaunchOptions: false ];
265+ }
266+
267+ /* !
268+ @method
269+
270+ @abstract creates an iterable session with launchOptions
271+
272+ @param launchOptions launchOptions from application:didFinishLaunchingWithOptions or custom launchOptions
273+
274+ @param useCustomLaunchOptions whether or not to use the custom launchOption without the UIApplicationLaunchOptionsRemoteNotificationKey
275+
276+ @return an instance of IterableAPI
277+ */
278+ - (instancetype )createSession : (NSDictionary *)launchOptions useCustomLaunchOptions : (BOOL )useCustomLaunchOptions
263279{
264280 // the url session doesn't depend on any options/params, so we'll use a singleton that gets created whenever the class is instantiated
265281 // if it gets instantiated again that's fine; we don't need to reconfigure the session, just keep using the old singleton
266282 [self createUrlSession ];
267283
268- if (launchOptions && launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]) {
269- // Automatically try to track a pushOpen
270- [self trackPushOpen: launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]];
284+ // Automatically try to track a pushOpen
285+ if (launchOptions) {
286+ if (useCustomLaunchOptions) {
287+ [self trackPushOpen: launchOptions];
288+ } else if (launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]) {
289+ [self trackPushOpen: launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]];
290+ }
271291 }
272292
273293 return self;
@@ -277,37 +297,49 @@ - (instancetype)createSession:(NSDictionary *)launchOptions
277297// / @name Implementations of things documents in IterableAPI.h
278298// ////////////////////////////////////////////////////////////
279299
300+ // documented in IterableAPI.h
301+ - (instancetype )initWithApiKey : (NSString *)apiKey andEmail : (NSString *)email
302+ {
303+ return [self initWithApiKey: apiKey andEmail: email launchOptions: nil ];
304+ }
305+
306+ // documented in IterableAPI.h
307+ - (instancetype )initWithApiKey : (NSString *)apiKey andUserId : (NSString *)userId
308+ {
309+ return [self initWithApiKey: apiKey andUserId: userId launchOptions: nil ];
310+ }
311+
280312// documented in IterableAPI.h
281313- (instancetype )initWithApiKey : (NSString *)apiKey andEmail : (NSString *)email launchOptions : (NSDictionary *)launchOptions
282314{
283- if (self = [super init ]) {
284- _apiKey = [apiKey copy ];
285- _email = [email copy ];
286- }
287-
288- return [self createSession: launchOptions];
315+ return [self initWithApiKey: apiKey andEmail: email launchOptions: launchOptions useCustomLaunchOptions: false ];
289316}
290317
291318// documented in IterableAPI.h
292319- (instancetype )initWithApiKey : (NSString *)apiKey andUserId : (NSString *)userId launchOptions : (NSDictionary *)launchOptions
293320{
294- if (self = [super init ]) {
295- _apiKey = [apiKey copy ];
296- _userId = [userId copy ];
297- }
298- return [self createSession: launchOptions];
321+ return [self initWithApiKey: apiKey andUserId: userId launchOptions: launchOptions useCustomLaunchOptions: false ];
299322}
300323
301324// documented in IterableAPI.h
302- - (instancetype )initWithApiKey : (NSString *)apiKey andEmail : (NSString *)email
325+ - (instancetype )initWithApiKey : (NSString *)apiKey andEmail : (NSString *)email launchOptions : ( NSDictionary *) launchOptions useCustomLaunchOptions : ( BOOL ) useCustomLaunchOptions
303326{
304- return [self initWithApiKey: apiKey andEmail: email launchOptions: nil ];
327+ if (self = [super init ]) {
328+ _apiKey = [apiKey copy ];
329+ _email = [email copy ];
330+ }
331+
332+ return [self createSession: launchOptions useCustomLaunchOptions: useCustomLaunchOptions];
305333}
306334
307335// documented in IterableAPI.h
308- - (instancetype )initWithApiKey : (NSString *)apiKey andUserId : (NSString *)userId
336+ - (instancetype )initWithApiKey : (NSString *)apiKey andUserId : (NSString *)userId launchOptions : ( NSDictionary *) launchOptions useCustomLaunchOptions : ( BOOL ) useCustomLaunchOptions
309337{
310- return [self initWithApiKey: apiKey andUserId: userId launchOptions: nil ];
338+ if (self = [super init ]) {
339+ _apiKey = [apiKey copy ];
340+ _userId = [userId copy ];
341+ }
342+ return [self createSession: launchOptions useCustomLaunchOptions: useCustomLaunchOptions];
311343}
312344
313345// documented in IterableAPI.h
0 commit comments