Shared Instance
Overview
Use this method to access the main object with which you can access to all the API functionality.
Signature
+ (Messangi *)sharedInstance;
Usage
Messangi *messangi = [Messangi sharedInstance];
Returns
This method returns the shared instance of the Messangi's object.
Init Messangi
Overview
One of the first init steps, this method will start the Fences & Beacon monitoring process.
Signature
- (void)initMessangi:(BOOL)first;
Parameters
Parameter Name | Description | Possible Values |
---|---|---|
first | Indicates if this user is already registered so all related services will start at this point. If not registered an additional dialog will be shown, allowing the user to register his mobile number. | true false |
Usage
[[Messangi sharedInstance] initMessangi:true];
Init Messangi
Overview
One of the first init steps, this method will start the Fences & Beacon monitoring process.
Signature
- (void)initMessangi;
Parameters
None
Usage
[[Messangi sharedInstance] initMessangi:true];
Set App Name
Overview
Set the Name for your App, useful if you have more that one iOS App to use with Messangi SDK
Signature
- (void)setAppName:(NSString *)newName;
Parameters
Parameter Name | Description | Possible Values |
---|---|---|
newName | The desired app name | NSString * |
Usage
[[Messangi sharedInstance] setAppName: @"example_app_name"];
Set the Client Identification
Overview
As part of the initialization process you need to set you ID as a client to Messangi SDK, this allow Messangi SDK to route properly your traffic to your App.
Signature
- (void)setClientID:(NSString *)newClientID;
Parameters
Parameter Name | Description | Possible Values |
---|---|---|
newClientID | Your Client ID | NSString * |
Usage
[[Messangi sharedInstance] setClientID: @"example_client_id"];
Set the Client Private Key
Overview
When you complete the registration process with the Messangi SDK team, you will receive some credentials values as a Messangi's client.
One of those credentials is a private key, you need to use this private key when you are conecting your app with Messangi SDK. The SDK will use it internally to sign properly all your requests.
The private key will never leave your app scope.
Signature
- (void)setApiClientPrivateKey:(NSString *)newPrivateKey;
Parameters
Parameter Name | Description | Possible Values |
---|---|---|
newPrivateKey | Your Messangi SDK private's key | NSString * |
Usage
[[Messangi sharedInstance] setApiClientPrivateKey: @"example_private_key"];
Set the Subscription URL
Overview
This URL is related to the Campaign Manager where you want to have and manage your distribution lists. It will be used every time the user wants to join or leave a distribution list.
Signature
- (void)setSubscriptionURL:(NSString *)newURL;
Parameters
Parameter Name | Description | Possible Values |
---|---|---|
newURL | The desired URL | NSString * |
Usage
[[Messangi sharedInstance] setSubscriptionURL:@"example_url_base/rest/api"];
Set the Subscription Workspace ID
Overview
This ID is related to the workspace on the Campaign Manager which you want to work with. It will be used every time the user wants to join or leave a distribution list.
Signature
- (void)setSubscriptionInstanceID:(NSString *)newID;
Parameters
Parameter Name | Description | Possible Values |
---|---|---|
newID | The desired workspace ID | NSString * |
Usage
[[Messangi sharedInstance] setSubscriptionInstanceID:@"example_workspace_id"];
Subscribe the device with Messangi SDK
Overview
As part of the initialization process, this method will establish a bind between the device and the Messangi SDK, this bind will be used for sending PUSH notifications to the device.
This method is used internally by registerDeviceToken method.
Signature
- (void)deviceSubscriberWithUniqueID;
Usage
[[Messangi sharedInstance] deviceSubscriberWithUniqueID];
Register Device Token
Overview
Generates an unique device identifier and register the device with Messangi SDK.
Signature
- (void)registerDeviceToken:(NSData *)deviceToken;
Parameters
Parameter Name | Description | Possible Values |
---|---|---|
deviceToken | This is the device token Apple provides when register your app with the APNs, you will receive this parameter through didRegisterForRemoteNotificationsWithDeviceToken method | NSData |
Usage
[[Messangi sharedInstance] registerDeviceToken:deviceToken];
Refresh Monitored Regions
Overview
In iOS like in other mobile OS it's possible to monitor geographical regions, by monitoring it, the device is capable of trigger an event when gets inside of a given area. Unfortunately iOS limits the amount of simultaneous geographical fences to 20. Read more about this at the Developer's Apple online documentation.
This method will review the proximity and conditions of all relevant GeoFences and select the closest 20 from the global list to keep track of those, please note that this method will also be used by Messangi SDK itself.
Signature
- (void)refreshMonitoredRegionsToClosest;
Usage
[[Messangi sharedInstance] refreshMonitoredRegionsToClosest];
Subscribe To Distribution List
Overview
You can create multiples Distribution Lists with the Campaign Manager to reach different user's groups.
Those Distributions Lists can be populated using multiples techniques, this method allows the user to suscribe to a List.
Signature
- (void)subscribeToList:(NSString *)subscriptionID;
Parameters
Parameter Name | Description | Possible Values |
---|---|---|
subscriptionID | The subscription id to be added | NSString * |
Usage
[[Messangi sharedInstance] subscribeToList:@"example_value"];
Unsubscribe From Distribution List
Overview
You can create multiples Distribution Lists with the Campaign Manager to reach different user's groups.
Registered users can leave a list any time they want, this method allows the user to unsubscribe from a list.
Signature
- (void)unsubscribeFromList:(NSString *)subscriptionID;
Parameters
Parameter Name | Description | Possible Values |
---|---|---|
subscriptionID | The subscription id to be removed | NSString * |
Usage
[[Messangi sharedInstance] unsubscribeFromList:@"example_value"];
Passing incoming PUSH to Messangi
Overview
We recommend when using Messangi SDK passing every PUSH notification you receive to the SDK first, if the PUSH is not relevant to the SDK it will let you handle the message your own way.
The SDK spect multiples message types, most of those are silent to the user, that's why we recommend to let the SDK process the incoming PUSH notification first.
Signature
- (BOOL)didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler;
Parameters
Parameter Name | Description | Possible Values |
---|---|---|
userInfo | Holding the msgId and type values | NSDictionary * |
completionHandler | Handler to be notified when completed | void (^)(UIBackgroundFetchResult) |
Usage
When you are working with PUSH notifications you need to override the didReceiveRemoteNotification method, we recommend to do it as follow to ensure the SDK work properly.
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { if ([[Messangi sharedInstance] didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler]) { /* * Messangi SDK already handled the PUSH notification * You can add code here to performing an additional operation */ } else { /* * Notification received was not wanted by Messangi * This notification must be managed by host App here */ } }
Returns
true if the PUSH was processed by the SDK, false if not
Get Unread Messages
Overview
This method is used internally by messangi's didReceiveRemoteNotification method. It will fetch all pending messages you have stored at Messangi.
Signature
- (void)getUnreadMessages;
Usage
[[Messangi sharedInstance] getUnreadMessages];
Start Location Services
Overview
Start Apple's Location Services from CoreLocation Framework. This method is internally called by initMessangi method.
Signature
- (void)startStandardUpdates;
Usage
[[Messangi sharedInstance] startStandardUpdates];
Report Current Location
Overview
This in an internal method, this method report the current device location and is automatically fired by didReceiveRemoteNotification method.
Signature
- (void)sendLastLocationForMsgID:(NSString *)msgID withHandler:(void (^)(UIBackgroundFetchResult))completionHandler;
Parameters
Parameter Name | Description | Possible Values |
---|---|---|
msgID | The incoming message id for which the location is reported | NSString * |
completionHandler | Handler to be notified when completed | void (^)(UIBackgroundFetchResult) |
Usage
[[Messangi sharedInstance] sendLastLocationForMsgID:ex_msgID withHandler:ex_completionHandler];
Location Services Status
Overview
This method verifies if the location services are ON at the moment
Signature
- (BOOL)statusLocationServicesOK;
Usage
[[Messangi sharedInstance] statusLocationServicesOK]
Returns
true if the location service is ON, false if not
Monitored GeoFences
Overview
Return all GeoFences currently monitored by the App.
Signature
- (NSSet *)monitoredGeoFences;
Usage
[Messangi monitoredGeoFences]
Returns
Log Event
Overview
Log events with Messangi SDK, they will be available to review later in our Kibana
Signature
- (void)logEvent:(NSString *)eventType andExtraInfo:(NSString *)extraInfo;
Parameters
Usage
[[Messangi sharedInstance] logEvent:@"example_type" andExtraInfo:@"example_additional_info"];