=== Notes === Please review the [[sdkoverview|SDK Overview]] for information on how the SDK connects the mobile app with the Campaign Manager. === iOS Integration === The iOS Messangi SDK is distributed as a Cocoa Touch Static Library. To add the library to your project drag and drop the static library into your project’s Frameworks inside Xcode. Add the following import to your Application’s **AppDelegate**: #import You will also need to import the **AdSupport** library: #import Messangi uses the Advertising Identifier (IDFA) adhering to the current best practice to uniquely identify a device. When submitting the host app to the App Store, the use of the IDFA needs to be declared as option 3, //Attribute an action taken within this app to a previously served advertisement//: \\ \\ {{ :ios-ad.png?800 }} \\ \\ Initialize the Messangi SDK in your **AppDelagate** **didFinishLaunchingWithOptions** method with your Messangi **App Name**, **Client ID** and **Private Key**: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { … NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [[Messangi sharedInstance] setAppName: @"Messangi"]; [[Messangi sharedInstance] setClientID: @"YDJBNYUD76236ppp5mq"]; [[Messangi sharedInstance] setApiClientPrivateKey: @"wzuuzVeVA8gf9aOOOxMC"]; [[Messangi sharedInstance] setSubscriptionURL:@"http://www.messangi.com/messangi_mmc/rest/api"]; [[Messangi sharedInstance] setSubscriptionInstanceID:@"8"]; if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)]) { UIUserNotificationType types = UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert; UIUserNotificationSettings *notificationSettings = [UIUserNotificationSettings settingsForTypes:types categories:nil]; [[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings]; } [[Messangi sharedInstance] initSubscriptions]; [[Messangi sharedInstance] initMessangi:true]; return YES; } If you use the **initMessangi:false** procedure, the Messangi SDK will show the authentication dialog so the user can enter his mobile number and complete the SMS validation process. However, you can always create your own validation UI to better match your Application’s L&F: \\ \\ {{ :validation.png?800 }} \\ \\ Should the user select Cancel option on the first screen, the [Messangi sharedInstance].useMessangiSDK variable is set to NO. This variable by default is set to YES. The following method should be implemented in **appDelegate** , otherwise the method **didRegisterForRemoteNotificationsWithDeviceToken** will never be invoked -(void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings { [application registerForRemoteNotifications]; } Implement the **didRegisterForRemoteNotificationsWithDeviceToken** method in your **AppDelegate** and forward the token to the Messangi SDK: - (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { // Remote notification registration was successful [[Messangi sharedInstance] registerDeviceToken:deviceToken]; } Implement the **didReceiveRemoteNotification** method in your **AppDelegate** and forward incoming push notifications to the Messangi SDK: - (void)application:(UIApplication *)application didReceiveRemoteNotification: (NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { // Remote notification was received [[Messangi sharedInstance] didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler]); } The use of Remote Notification in Background modes needs to be selected in the host App capabilities: \\ \\ {{ :capabilities.png?600 }} \\ \\ Implement the messageLoadFinishedReturningMessage method in your AppDelegate. This method will receive all the Messangi push notifications after they’ve been completely retrieved from the server: -(void) messageLoadFinishedReturningMessage:(UnstoredIncomingMessage *) message { NSLog(@"WAAppDelegate: messageLoadFinishedReturningMessage"); // This method will be called every time the user receives a push notification // via Messangi and the field title and body has been retrieved from the server. // Use this method to display the content of the notification. } Please refer to the Messangi Demo Application for additional code samples. \\ \\ === logEvent Facility === Events can be generated in the Analytics platform via the logEvent facility. You only need to provide the EVENT_TYPE and EXTRA_INFO. Please refer to [[Data Structure]], [[Events]], [[Location]], [[Aggregation]] and [[Dashboard]] for more information: \\ \\ [[Messangi sharedInstance] logEvent:@"EVENT_NAME" andExtraInfo:@"EXTRA_INFO"]; \\ Please refer to [[Analytics Overview]] for more information on events and dashboards.