Advanced Usage

Specify a custom campaign tag

By default if no campaign tag was specified, SDK uses ios-invite and ios-post-purchase tags for Standalone and Post Purchase campaigns. But you can explicitly specify your own tag in this way:

#import <TalkableSDK/Talkable.h>
// ...
[[Talkable manager] registerOrigin:TKBLAffiliateMember params:@{TKBLCampaignTags: @"your-custom-tag"}];

Implement TalkableDelegate

  1. Assign your ViewController or other object as Talkable delegate by using the following code:

[[Talkable manager] setDelegate: yourObjectConformsToTalkableDelegateProtocol];
  1. Take control of presenting offers to your users. Use the next two delegate methods to prevent or give an instruction as to where you want that offer to be displayed:

- (BOOL)shouldPresentTalkableOfferViewController:(UIViewController*)controller;
- (UIViewController*)viewControllerForPresentingTalkableOfferViewController;
  1. Customize ViewContoller title by implementing the method below. By default, title of offer page is used.

- (NSString*)titleForTalkableOfferViewController:(UIViewController*)controller;

Note

You can modify page title on a Talkable Site during campaign development.

  1. Present offers to your users by yourself by handling request url or webView after origin was created.

- (void)didRegisterOrigin:(TKBLOriginType)type withURL:(NSURL*)url;
- (void)didRegisterOrigin:(TKBLOriginType)type withWebView:(WKWebView*)webView;

Note

Talkable SDK assigns itself to WKWebView navigation delegate. Changing WKWebView navigation delegate may break some functionality so we strictly recommend not doing this.

  1. Manage cases where origin wasn’t created or offer hasn’t been presented.

- (void)registerOrigin:(TKBLOriginType)type didFailWithError:(NSError*)error;

Note

userInfo may contain detailed information about the error.

  1. Receive notification when the user taps Facebook or Twitter sharing button in the WebView and trigger corresponding sharing view.

    - (void)showFacebookShareDialogWithParams:(NSDictionary*)params delegate:(id)delegate;
    - (void)showFacebookShareDialogWithParams:(NSDictionary*)params completion:(void (^)())completionHandler;
    - (void)showTwitterShareDialogWithParams:(NSDictionary*)params completion:(void (^)())completionHandler;
    

    Note

    See Social Sharing for details.

Notifications

Subscribe to notifications that Talkable SDK publish and be aware of everything that happens around your campaigns.

  1. Receive the coupon given to your users:

#import <TalkableSDK/Talkable.h>
// ...
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(couponReceived:) name:TKBLDidReceiveCouponCode object:nil];
// ...
- (void)couponReceived:(NSNotification*)ntf {
  // Your logic here
}
  1. Catch every message from presented offer:

#import <TalkableSDK/Talkable.h>
// ...
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(publishMessageNotification:) name:TKBLDidPublishMessageNotification object:nil];
// ...
- (void)publishMessageNotification:(NSNotification*)ntf {
  if ([[[ntf userInfo] objectForKey:TKBLMessageNameKey] isEqualToString:TKBLMessageOfferLoaded]) {
    // Your logic here
  }
}

Available messages:

  • TKBLMessageOfferLoaded

  • TKBLMessageOfferClose

  • TKBLMessageCouponIssued

Contacts Import

It is possible to import contacts from a device with the SDK, so they will be accessible at the Share page with JavaScript. The button at the Share page for contacts importing should have class=”js-import-contacts” property.

Also, contacts usage description is required on iOS 10+ devices. It should be described under the NSContactsUsageDescription key in the Info.plist file of your app. This message will be shown when asking for contacts permissions.

<key>NSContactsUsageDescription</key>
<string>Share the offer with your Friends from contacts</string>

Note

Talkable SDK asks for the contacts permissions dynamically only when “contacts import” functionality is implemented in the campaign and Advocate presses the corresponding button at the Share page for the first time.

Debugging

See all debugging information in your console which can help you to understand what is going wrong:

#import <TalkableSDK/Talkable.h>
// ...
[Talkable manager].debug = YES;