Option 3 - Manual Integration In iOS App- Objective-C


Goal

To add the SDK to your apps code by manual integration, preform the following steps.

Attention

This topic covers a manual method that gives you greater control, and lets you override behaviour. For an automatic (basic)  process, see iOS SDK Basic Automatic Integration for Mapp Cloud

Prerequisites

  • Xcode application with a base SDK of iOS 11 and above.
  • Xcode application with a deployment target of iOS 11 and above.
  • An account on the Appoxee dashboard with a configured application.

Procedure

1. Download the SDK from Mapp Cloud Mobile Integration

2. Drag AppoxeeSDK.framework into you project, or see link Integrate Mobile Push SDK for iOS (Mapp Cloud) 

3. Open your AppDelegate.m file, and add the following import statement:

#import <AppoxeeSDK/AppoxeeSDK.h>


If you are adding AppoxeeSDK.xcframework import statement need to look like this:

#import AppoxeeSDK.h"

4. Add the following delegate notation (can also be added at AppDelegate.h):


@interface AppDelegate() <AppoxeeNotificationDelegate>
@end


5. Add the following implementation to the method named: application:didFinishLaunchingWithOptions:, Where, xxx.xxx represents the SDK ID. These were created for you with the Appoxee Dashboard:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
   [[Appoxee shared] engageWithLaunchOptions:launchOptions andDelegate:self andSDKID:@"xxx.xxx" with: L3];
   
   // Insert other initialization code or other Frameworks code below.
   
   return YES;
}

 For parameter "with" see the description.

6. Add the following implementation to the method named: application:didRegisterForRemoteNotificationsWithDeviceToken:


 - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
   [[Appoxee shared] didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}


7. Add the following implementation to the method named: application:didReceiveRemoteNotification:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
    [[Appoxee shared] receivedRemoteNotification:userInfo];
}


8. Add the following implementation to the method named: application:didRegisterUserNotificationSettings (deprecated method -  will be updated with new version of SDK:

 - (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
   [[Appoxee shared] didRegisterUserNotificationSettings:notificationSettings];
}


9. OPTIONAL STEP -  To implement iOS8 'Push Actions', add the following implementation to the method named: application:handleActionWithIdentifier:forRemoteNotification:completionHandler:

 - (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void (^)())completionHandler
{
   // Must be implemented in order to enable 'Push Actions'.
   BOOL didHandle = [[Appoxee shared] handleActionWithIdentifier:identifier forRemoteNotification:userInfo completionHandler:completionHandler];
   
   if (!didHandle) { completionHandler(); } // Handle the action in case it is not handled by Appoxee. When done - completionHandler() must be called.
}


10. OPTIONAL STEP – Silent push

Please review the documentation provided with the SDK for the below methods :

- handleActionWithIdentifier:forRemoteNotification:completionHandler:
- didReceiveRemoteNotification:fetchCompletionHandler:andNotifyCompletionWithBlock:


11. OPTIONAL STEP - Appoxee delegate:

#pragma mark - AppoxeeDelegate
- (void)Appoxee:(Appoxee *)appoxee handledRemoteNotification:(APXPushNotification *)pushNotification andIdentifer:(NSString *)actionIdentifier
{
   // a push notification was recieved.
}