In an automated integration, the AppDelegate replacement method sends method calls to your application’s real AppDelegate. If you do not want to rely on the AppDelegate replacement method, you can perform a manual integration.

In a manual integration, you add code to the AppDelegate.m file in your app instead of the MCEAppDelegate.m file in the SDK. Additionally, perform the following steps:

  • Set Other Linker Flags to -ObjC.
  • Copy MceConfig.json to your project. Modify MceConfig.json to include your app keys.
  • Remove the appDelegateClass section from MceConfig.json.
  • Add the Push Notifications Capability to the target settings. For instructions, see Setting up iOS apps (step 1) in Set up your iOS app in Apple.
  • Attach images, videos, and sound by following the instructions for adding the notification service. For instructions, see Adding media attachments to push notifications in iOS 10.

Attention:

  • The automated integration method of replacing AppDelegate is recommended for ease of integration and upgrading. Some integration issues might occur if you use the manual integration method.
  • When integrating manually, remember to remove the appDelegateClass section of your MceConfig.json file.
    • 
      
      #import <AcousticMobilePush/AcousticMobilePush.h>
      -(void)applicationDidFinishLaunching:(UIApplication *)application
      {
          [[MCESdk sharedInstance] handleApplicationLaunch];
      	[application registerForRemoteNotifications];
      
          NSUInteger options = 0;
          if(@available(iOS 12.0, *)) {
              options = UNAuthorizationOptionAlert|UNAuthorizationOptionSound|UNAuthorizationOptionBadge|UNAuthorizationOptionCarPlay|UNAuthorizationOptionProvidesAppNotificationSettings;
          } else {
              options = UNAuthorizationOptionAlert|UNAuthorizationOptionSound|UNAuthorizationOptionBadge|UNAuthorizationOptionCarPlay;
          }
      
          UNUserNotificationCenter * center = [UNUserNotificationCenter currentNotificationCenter];
          [center requestAuthorizationWithOptions: options completionHandler:^(BOOL granted, NSError * _Nullable error) {
              
              // This isn't required, it's here to demonstrate how to register static category actions
              [center setNotificationCategories: [self applicationCategories]];
          }];
      }
      
      -(void) application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
          [[MCESdk sharedInstance]registerDeviceToken:deviceToken];
      }
      
      -(void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error{
          [[MCESdk sharedInstance]deviceTokenRegistartionFailed];
      }
      

      Need more help? Check out all of our available tutorials for mobile app messaging here:

      All Mobile Application Messaging Tutorials

      3 comments on"Manually integrating the iOS SDK using Objective-C"

      1. [[MCESdk sharedInstance]registerDeviceToken:deviceToken];

        If this fails first time due to network connectivity issue or any other issue, This is not returning mobile user id and push token on second and third retry.

      2. The block passed to requestAuthorizationWithOptions needs to run on main thread. Wrap it in a dispatch_async(dispatch_get_main_queue(), …)

      Join The Discussion

      Your email address will not be published. Required fields are marked *