@@ -345,6 +345,55 @@ - (instancetype)createSession:(NSDictionary *)launchOptions useCustomLaunchOptio
345345// / @name Implementations of things documents in IterableAPI.h
346346// ////////////////////////////////////////////////////////////
347347
348+ // documented in IterableAPI.h
349+ + (IterableAPI *)sharedInstance
350+ {
351+ if (sharedInstance == nil ) {
352+ LogError (@" [sharedInstance called before sharedInstanceWithApiKey" );
353+ }
354+ return sharedInstance;
355+ }
356+
357+ // documented in IterableAPI.h
358+ + (IterableAPI *)sharedInstanceWithApiKey : (NSString *)apiKey andEmail : (NSString *)email launchOptions : (NSDictionary *)launchOptions
359+ {
360+ // threadsafe way to create a static singleton https://stackoverflow.com/questions/5720029/create-singleton-using-gcds-dispatch-once-in-objective-c
361+ static dispatch_once_t onceToken;
362+ dispatch_once (&onceToken, ^{
363+ sharedInstance = [[IterableAPI alloc ] initWithApiKey: apiKey andEmail: email launchOptions: launchOptions];
364+ });
365+ return sharedInstance;
366+ }
367+
368+ // documented in IterableAPI.h
369+ + (IterableAPI *)sharedInstanceWithApiKey : (NSString *)apiKey andUserId : (NSString *)userId launchOptions : (NSDictionary *)launchOptions
370+ {
371+ // threadsafe way to create a static singleton https://stackoverflow.com/questions/5720029/create-singleton-using-gcds-dispatch-once-in-objective-c
372+ static dispatch_once_t onceToken;
373+ dispatch_once (&onceToken, ^{
374+ sharedInstance = [[IterableAPI alloc ] initWithApiKey: apiKey andUserId: userId launchOptions: launchOptions];
375+ });
376+ return sharedInstance;
377+ }
378+
379+ // documented in IterableAPI.h
380+ +(void ) getAndTrackDeeplink : (NSURL *)webpageURL callbackBlock : (ITEActionBlock)callbackBlock
381+ {
382+ NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern: ITBL_DEEPLINK_IDENTIFIER options: 0 error: NULL ];
383+ NSString *urlString = webpageURL.absoluteString ;
384+ NSTextCheckingResult *match = [regex firstMatchInString: urlString options: 0 range: NSMakeRange (0 , [urlString length ])];
385+
386+ if (match == NULL ) {
387+ callbackBlock (webpageURL.absoluteString );
388+ } else {
389+ NSURLSessionDataTask *trackAndRedirectTask = [[NSURLSession sharedSession ]
390+ dataTaskWithURL: webpageURL completionHandler: ^(NSData *data, NSURLResponse *response, NSError *error) {
391+ callbackBlock (response.URL .absoluteString );
392+ }];
393+ [trackAndRedirectTask resume ];
394+ }
395+ }
396+
348397// documented in IterableAPI.h
349398- (instancetype )initWithApiKey : (NSString *)apiKey andEmail : (NSString *)email
350399{
@@ -437,41 +486,6 @@ - (void)trackInAppClick:(NSNumber*)campaignId templateId:(NSNumber*)templateId m
437486 [self sendRequest: request onSuccess: [IterableAPI defaultOnSuccess: @" trackInAppClick" ] onFailure: [IterableAPI defaultOnFailure: @" trackInAppClick" ]];
438487}
439488
440- // ////////////////////////////////////////////////////////////
441- // / @name Implementations of things documents in IterableAPI.h
442- // ////////////////////////////////////////////////////////////
443-
444- // documented in IterableAPI.h
445- + (IterableAPI *)sharedInstance
446- {
447- if (sharedInstance == nil ) {
448- LogError (@" [sharedInstance called before sharedInstanceWithApiKey" );
449- }
450- return sharedInstance;
451- }
452-
453- // documented in IterableAPI.h
454- + (IterableAPI *)sharedInstanceWithApiKey : (NSString *)apiKey andEmail : (NSString *)email launchOptions : (NSDictionary *)launchOptions
455- {
456- // threadsafe way to create a static singleton https://stackoverflow.com/questions/5720029/create-singleton-using-gcds-dispatch-once-in-objective-c
457- static dispatch_once_t onceToken;
458- dispatch_once (&onceToken, ^{
459- sharedInstance = [[IterableAPI alloc ] initWithApiKey: apiKey andEmail: email launchOptions: launchOptions];
460- });
461- return sharedInstance;
462- }
463-
464- // documented in IterableAPI.h
465- + (IterableAPI *)sharedInstanceWithApiKey : (NSString *)apiKey andUserId : (NSString *)userId launchOptions : (NSDictionary *)launchOptions
466- {
467- // threadsafe way to create a static singleton https://stackoverflow.com/questions/5720029/create-singleton-using-gcds-dispatch-once-in-objective-c
468- static dispatch_once_t onceToken;
469- dispatch_once (&onceToken, ^{
470- sharedInstance = [[IterableAPI alloc ] initWithApiKey: apiKey andUserId: userId launchOptions: launchOptions];
471- });
472- return sharedInstance;
473- }
474-
475489// documented in IterableAPI.h
476490- (void )registerToken : (NSData *)token appName : (NSString *)appName pushServicePlatform : (PushServicePlatform)pushServicePlatform
477491{
@@ -807,11 +821,13 @@ - (void)getInAppMessages:(NSNumber *)count onSuccess:(OnSuccessHandler)onSuccess
807821 [self sendRequest: request onSuccess: onSuccess onFailure: onFailure];
808822}
809823
824+ // documented in IterableAPI.h
810825-(void ) showSystemNotification : (NSString *)title body : (NSString *)body button : (NSString *)button callbackBlock : (ITEActionBlock)callbackBlock
811826{
812827 [IterableInAppManager showSystemNotification: title body: body buttonLeft: button buttonRight: nil callbackBlock: callbackBlock];
813828}
814829
830+ // documented in IterableAPI.h
815831-(void ) showSystemNotification : (NSString *)title body : (NSString *)body buttonLeft : (NSString *)buttonLeft buttonRight : (NSString *)buttonRight callbackBlock : (ITEActionBlock)callbackBlock
816832{
817833 [IterableInAppManager showSystemNotification: title body: body buttonLeft: buttonLeft buttonRight: buttonRight callbackBlock: callbackBlock];
0 commit comments