Pyze

@interface Pyze : NSObject

Pyze main class

This is the main class for the Pyze iOS SDK. Use method initializeWithKey: to initialize the Library. For troubleshooting during development and in debug mode, you can throttle the logging level using method debugLogThrottling: In the release mode or deployment the SDK will log minimally.

Please visit Pyze Developer Center for more information.

You will need an app-specific key Pyze App Key from: growth.pyze.com

  • Initializes the Pyze library. Call this method in the app delegate’s method application:willFinishLaunchingWithOptions. Get Pyze App Key from growth.pyze.com

    Usage:

      [Pyze initialize:@"Pyze App Key obtained from growth.pyze.com"];
    

    Warning

    Important: Get an app-specific key from growth.pyze.com

    Since

    2.0.5

    Declaration

    Objective-C

    + (void)initialize:(NSString *)pyzeAppKey;

    Swift

    class func initialize(_ pyzeAppKey: String!)

    Parameters

    pyzeAppKey

    The app-specific key obtained from growth.pyze.com

  • Initializes the Pyze library and specify the log throttling level. Call this method in the app delegate’s method application:willFinishLaunchingWithOptions. Get Pyze App Key from growth.pyze.com

    Usage:

      [Pyze initialize:@"Pyze App Key obtained from growth.pyze.com"   withLogThrottling: PyzelogLevelAll];
    

    Warning

    Important: Get an app-specific key from growth.pyze.com

    Since

    2.3.3 (added for consistency with Android and Unity agents)

    Declaration

    Objective-C

    + (void)initialize:(NSString *)pyzeAppKey
        withLogThrottling:(PyzeLogLevel)logLevel;

    Swift

    class func initialize(_ pyzeAppKey: String!, withLogThrottling logLevel: PyzeLogLevel)

    Parameters

    pyzeAppKey

    The app-specific key obtained from growth.pyze.com

    logLevel

    Log level you would wish to see in the console.

  • Log throttling level can be changed anytime in the app

    How to use:

    [Pyze logThrottling:PyzelogLevelMinimal];
    

    or

    [Pyze logThrottling:PyzelogLevelErrors];
    

    Since

    2.0.5

    Declaration

    Objective-C

    + (void)logThrottling:(PyzeLogLevel)logLevel;

    Swift

    class func logThrottling(_ logLevel: PyzeLogLevel)

    Parameters

    logLevel

    Log level you would wish to see in the console.

  • Pyze Timer Reference is a time interval since a Pyze internal reference time in seconds with millisecond precision e.g. 6.789 seconds (or 6789 milliseconds)

    It is used to time tasks and report in events.

    usage:

     //Start timing
     double referenceFileUploadStart = [Pyze timerReference];
     ...
     ...
     //time and send elapsedSeconds
     [PyzeCustomEvent postWithEventName:@“File Uploaded”
                     withTimerReference:referenceFileUploadStart];
    

    Declaration

    Objective-C

    + (double)timerReference;

    Swift

    class func timerReference() -> Double
  • Use this API to set the push notification device token. This will trigger Pyze to update the device token, which internally would be used to send the push notification. Call this API in Application’s AppDelegate method application:didRegisterForRemoteNotificationsWithDeviceToken:.

    Since

    2.2.1

    Declaration

    Objective-C

    + (void)setRemoteNotificationDeviceToken:(NSData *)deviceToken;

    Swift

    class func setRemoteNotificationDeviceToken(_ deviceToken: Data!)

    Parameters

    deviceToken

    device Token bytes received from the AppDelegate’s method call.

  • Use this API to process the push/remote notification. Call this everytime when you receive the remote notification from application:didReceiveRemoteNotification or application:didReceiveRemoteNotification:fetchCompletionHandler:.

    If you are using interactive push notifications e.g. Button handlers in push messages, then use processReceivedRemoteNotificationWithId: instead.

    Since

    2.2.1

    Declaration

    Objective-C

    + (void)processReceivedRemoteNotification:(NSDictionary *)userInfo;

    Swift

    class func processReceivedRemoteNotification(_ userInfo: [AnyHashable : Any]!)

    Parameters

    userInfo

    User information received as a payload.

  • Use this API to process the local/remote push notifications. Call this everytime when you receive the remote notification from application:handleActionWithIdentifier:forRemoteNotification:completionHandler:. For example: Button handlers in interactive push notifications. If you are not using button handlers in push messages, you can pass nil to ‘identifer’ parameter.

    Since

    2.9.1

    Declaration

    Objective-C

    + (void)processReceivedRemoteNotificationWithId:(NSString *)identifer
                                       withUserInfo:(NSDictionary *)userInfo;

    Swift

    class func processReceivedRemoteNotification(withId identifer: String!, withUserInfo userInfo: [AnyHashable : Any]! = [:])

    Parameters

    userInfo

    User information received as a payload.

  • This will add a badge to the UIControl (e.g.: UIButton) depicting the number of unfetched and new in-app messages available. *
  • Since

    2.3.2

    Declaration

    Objective-C

    + (void)addBadge:(UIControl *)control;

    Swift

    class func addBadge(_ control: UIControl!)

    Parameters

    control

    UIControl to add badge to.

  • Show in-app unread messages with default settings. For all the controls presented including Message Navigation Bar, buttons will loaded with default presentation colors used by the SDK. When user taps on any of the buttons in in-app message completionhandler method will be called.

      [Pyze countNewUnFetched:^(NSInteger result) {
          if (result > 0) {
              [Pyze showUnreadInAppNotificationUIWithCompletionHandler:^(PyzeInAppStatus *inAppStatus) {
                  NSLog(@"buttonIndex = %d", (int)inAppStatus.buttonIndex);
                  NSLog(@"message-ID =%@" , inAppStatus.messageID);
                  NSLog(@"campaign-ID = %@", inAppStatus.campaignID);
                  NSLog(@"title = %@",inAppStatus.title);
                  NSLog(@"urlString = %@",inAppStatus.urlString);
              }];
          }
      }];
    

    Since

    2.5.3

    Declaration

    Objective-C

    + (void)showUnreadInAppNotificationUIWithCompletionHandler:
        (void (^)(PyzeInAppStatus *))completionhandler;

    Swift

    class func showUnreadInAppNotificationUI(completionHandler completionhandler: ((PyzeInAppStatus?) -> Void)!)

    Parameters

    completionhandler

    Completion handler

  • Convenience method to show in-app message with custom colors as required by the app. When user taps on any of the buttons in in-app message completionhandler method will be called. The call-to-action (upto 3) button colors are defined in the UI on growth.pyze.com when creating an in-app message. The navigation text color to move between in-app messages e.g. ’<’ | ’>’ are defined using navigationTextColor parameter in this method.

    Since

    2.9.0

    Declaration

    Objective-C

    + (void)showInAppNotificationUIForDisplayMessages:
                (PyzeInAppMessageType)messageType
                                  navigationTextColor:(UIColor *)textColor
                                withCompletionHandler:
                                    (void (^)(PyzeInAppStatus *))completionhandler;

    Swift

    class func showInAppNotificationUI(forDisplayMessages messageType: PyzeInAppMessageType, navigationTextColor textColor: UIColor!, withCompletionHandler completionhandler: ((PyzeInAppStatus?) -> Void)!)

    Parameters

    messageType

    The in-app message type you would want to see. Default is PyzeInAppTypeUnread.

    navigationTextColor

    Navigation text color (Ex: 1 of 10) and chevrons.

    completionhandler

    Completion handler

  • Dismisses the in-app notification UI.

    Since

    3.0.1

    Declaration

    Objective-C

    + (void)dismissInAppNotificationUI:(BOOL)animated;

    Swift

    class func dismiss(inAppNotificationUI animated: Bool)

    Parameters

    animated

    On YES, dismissed the In-app UI.

  • Returns the messageHeaders and messageBody from the server and from the cache based on the messageType.

    Since

    2.8.2

    Declaration

    Objective-C

    + (void)getMessagesForType:(PyzeInAppMessageType)messageType
         withCompletionHandler:(void (^)(NSArray *))completionHandler;

    Swift

    class func getMessagesFor(_ messageType: PyzeInAppMessageType, withCompletionHandler completionHandler: (([Any]?) -> Void)!)

    Parameters

    messageType

    Message type for in-app messages.

    completionHandler

    Completion handler will be called with result.

  • Returns the number of unread messages from the server.

    Since

    2.3.0

    Declaration

    Objective-C

    + (void)countNewUnFetched:(void (^)(NSInteger))completionHandler;

    Swift

    class func countNewUnFetched(_ completionHandler: ((Int) -> Void)!)

    Parameters

    completionHandler

    Completion handler will be called with count.

  • Get NSArray of message headers containing message ID and content ID.

    Since

    2.3.0

    Declaration

    Objective-C

    + (void)getMessageHeadersForType:(PyzeInAppMessageType)messageType
               withCompletionHandler:(void (^)(NSArray *))completionHandler;

    Swift

    class func getMessageHeaders(for messageType: PyzeInAppMessageType, withCompletionHandler completionHandler: (([Any]?) -> Void)!)

    Parameters

    messageType

    Message type for in-app messages.

    completionHandler

    Completion handler will be called with result.

  • Get message details with Campaign ID and message ID received from ‘getMessageHeadersForType’.

    Since

    2.3.0

    Declaration

    Objective-C

    + (void)getMessageBodyWithCampaignID:(NSString *)cid
                            andMessageID:(NSString *)messageID
                   withCompletionHandler:
                       (void (^)(NSDictionary *))completionHandler;

    Swift

    class func getMessageBody(withCampaignID cid: String!, andMessageID messageID: String!, withCompletionHandler completionHandler: (([AnyHashable : Any]?) -> Void)!)

    Parameters

    cid

    campaign ID

    messageID

    message ID

    completionHandler

    Completion handler will be called with message body.

  • Hash function can be used to convert any NSString to an hashed equivalent. The generated string is suffixed with two hash characters ## This function is useful to avoid collecting any information that may be private or sensitive.

    Since

    2.7.0

    Declaration

    Objective-C

    + (NSString *)hash:(NSString *)stringToHash;

    Swift

    class func hash(_ stringToHash: String!) -> String!

    Parameters

    stringToHash

    String to Hash

  • Deprecated in favor of static initialize: method

    See

    +initialize:

    Declaration

    Objective-C

    - (void)initializeWithKey:(NSString *)pyzeAppKey;

    Swift

    func initialize(withKey pyzeAppKey: String!)
  • Deprecated in favor of static method logThrottling:

    See

    +logThrottling:

    Declaration

    Objective-C

    - (void)logThrottling:(PyzeLogLevel)logLevel;

    Swift

    func logThrottling(_ logLevel: PyzeLogLevel)
  • Get the shared instance of Pyze API

    Declaration

    Objective-C

    + (Pyze *)sharedPyze;

    Swift

    class func shared() -> Pyze!

    Return Value

    Pyze instance type.

  • init method is unavailable. Use initializeWithKey: method instead.

    See

    initializeWithKey:

    Declaration

    Objective-C

    - (instancetype)init;

    Return Value

    instance type

  • Show in-app unread messages with default settings. For all the controls presented including Message Navigation Bar, buttons
  • will loaded with default presentation colors used by the SDK. When user taps on any of the buttons in in-app message
  • inAppMessageButtonHandlerWithIndex:buttonTitle:containingURLString:withDeepLinkStatus method will be called on your onViewController. *
  • See

    showUnreadInAppNotificationUIWithCompletionHandler:

  • Since

    2.3.0

    Declaration

    Objective-C

    + (void)showUnreadInAppNotificationUI:(UIViewController *)onViewController;

    Swift

    class func showUnread(inAppNotificationUI onViewController: UIViewController!)

    Parameters

    onViewController

    The controller on which the in-app should be presented.

  • Convenience method to show in-app message with custom colors as required by the app. When user taps on any of the buttons in in-app message inAppMessageButtonHandlerWithIndex:buttonTitle:containingURLString:withDeepLinkStatus method will be called on your onViewController.

    See

    showInAppNotificationUI: with completionHandler method.

    Since

    2.3.0

    Declaration

    Objective-C

    + (void)showInAppNotificationUI:(UIViewController *)onViewController
                 forDisplayMessages:(PyzeInAppMessageType)messageType
          msgNavBarButtonsTextColor:(UIColor *)buttonTextcolor
            msgNavBarButtonsBgColor:(UIColor *)buttonBackgroundColor
                   msgNavBarBgColor:(UIColor *)backgroundColor
          msgNavBarCounterTextColor:(UIColor *)messageCounterTextColor;

    Swift

    class func show(inAppNotificationUI onViewController: UIViewController!, forDisplayMessages messageType: PyzeInAppMessageType, msgNavBarButtonsTextColor buttonTextcolor: UIColor!, msgNavBarButtonsBgColor buttonBackgroundColor: UIColor!, msgNavBarBgColor backgroundColor: UIColor!, msgNavBarCounterTextColor messageCounterTextColor: UIColor!)

    Parameters

    onViewController

    The controller on which the in-app should be presented.

    messageType

    The in-app message type you would want to see. Default is PyzeInAppTypeUnread.

    buttonTextcolor

    Button text color.

    buttonBackgroundColor

    Button background color

    backgroundColor

    Translucent background color of the ‘MessageNavigationBar’

    messageCounterTextColor

    Message counter text color (Ex: 1 of 10 in-app messages).

  • Convenience method to show in-app message with custom colors as required by the app. When user taps on any of the buttons in in-app message completionhandler method will be called.

    See

    showInAppNotificationUIForDisplayMessages:navigationTextColor:withCompletionHandler: as alternative implementation.

    Since

    2.5.3

    Declaration

    Objective-C

    + (void)
    showInAppNotificationUIForDisplayMessages:(PyzeInAppMessageType)messageType
                    msgNavBarButtonsTextColor:(UIColor *)buttonTextcolor
                      msgNavBarButtonsBgColor:(UIColor *)buttonBackgroundColor
                             msgNavBarBgColor:(UIColor *)backgroundColor
                    msgNavBarCounterTextColor:(UIColor *)messageCounterTextColor
                        withCompletionHandler:
                            (void (^)(PyzeInAppStatus *))completionhandler;

    Swift

    class func showInAppNotificationUI(forDisplayMessages messageType: PyzeInAppMessageType, msgNavBarButtonsTextColor buttonTextcolor: UIColor!, msgNavBarButtonsBgColor buttonBackgroundColor: UIColor!, msgNavBarBgColor backgroundColor: UIColor!, msgNavBarCounterTextColor messageCounterTextColor: UIColor!, withCompletionHandler completionhandler: ((PyzeInAppStatus?) -> Void)!)

    Parameters

    messageType

    The in-app message type you would want to see. Default is PyzeInAppTypeUnread.

    buttonTextcolor

    Button text color.

    buttonBackgroundColor

    Button background color

    backgroundColor

    Translucent background color of the ‘MessageNavigationBar’

    messageCounterTextColor

    Message counter text color (Ex: 1 of 10).

    completionhandler

    Completion handler