Xamarin integration for iOS (Mapp Cloud)


Following is required to start SDK integration

  • Xcode and iOS SDK - Apple's Xcode and the latest iOS API need to be installed and configured on the developer's computer,
  • Xcode Command Line Tools - The Xcode Command Line Tools must be installed for the currently installed version of Xcode (see below for installation details),
  • Visual Studio for Mac or Visual Studio - The latest version of Visual Studio for Mac or Visual Studio should be installed and configured on the development computer. An Apple Mac is required for developing a Xamarin.iOS application, and when using Visual Studio you must be connected to a Xamarin.iOS build host
  • The latest version of Objective Sharpie - A current copy of the Objective Sharpie tool downloaded from here. If you already have Objective Sharpie installed, you can update it to the latest version by using the sharpie update.

Steps:


1.   From Visual Studio select “New Solution” From file Menu.


2.   Select iOS -> Library -> Binding Library and give a name to the library.


3. Xamarin  binding solution will be created like screenshot below


4. Copy libAppoxeeInapp.a & libAppoxeeSDK.a to the project folder.


5. Open libAppoxeeInapp.a and in libAppoxeeInapp.linkwith.cs file change SmartLink from true to false.


7. Open “ApiDefinition.cs” file from the sample project and copy code to the “ApiDefinition.cs” in the Xamarin app. Make sure not to change the namespace header at the top of the file.


8. Open “Struct.cs” file from the sample project and copy code to the “Struct.cs” in the Xamarin app. Make sure not to change the namespace header at the top of the file.


8. Add config.plist file to Xamarin code following link - iOS SDK Basic Automatic Integration for Mapp Cloud

9. Compile and run the application now.


10. Add New Project to the binding application by selecting “New Solution” From file Menu. Create SingleViewApplication under IOS->App.


11. Under created project add application binding as native reference.


12. Open AppDelegate.cs file and import Binding application. 

using Foundation;
using MappIosBinding;
using UIKit;


13. Open AppDelegate.cs from sample project and copy the methods required for push notifications integration.

Setup Appoxee delegates


public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
{
Appoxee.Shared().DidRegisterForRemoteNotificationsWithDeviceToken(deviceToken);
}
 
public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action<UIBackgroundFetchResult> completionHandler)
{
Appoxee.Shared().ReceivedRemoteNotification(userInfo);
}
 
public override void DidRegisterUserNotificationSettings(UIApplication application, UIUserNotificationSettings notificationSettings)
{
Appoxee.Shared().DidRegisterUserNotificationSettings(notificationSettings);
}


14. You must call Appoxee.Shared().EngageAndAutoIntegrateWithLaunchOptions(launchOptions, null, Server.Test) to start AppoxeeSDK. This will register the device with the Engage server and a device will be able to receive a notification.

If you want to enable in-app messages in your application you must call AppoxeeInapp.Shared().engageWithDelegate(AppoxeeInappdelegate, Inappserver.tEST). This method allows you to trigger in-app messages for specific events.


Appoxee.Shared().EngageAndAutoIntegrateWithLaunchOptions(launchOptions, null, Server.Test);
            
AppoxeeInapp.Shared().EngageWithDelegate(AppoxeeInappdelegate, Inappserver.tEST);

Appoxee.Shared().AddObserver(this, (NSString)"isReady", NSKeyValueObservingOptions.Old | NSKeyValueObservingOptions.New, (IntPtr)1);
Init location managers
public override void ObserveValue(NSString keyPath, NSObject ofObject, NSDictionary change, IntPtr context)
{
   if (keyPath == "isReady")
   {
       Appoxee.Shared().RemoveObserver(this, "isReady");
       locationDelegete = new LocationDelegate();
       AppoxeeLocationManager.Shared().Delegate = locationDelegete;
       AppoxeeLocationManager.Shared().LogLevel = 1;
       AppoxeeLocationManager.Shared().EnableLocationMonitoring();
   }
   else
   {
         base.ObserveValue(keyPath, ofObject, change, context);
   }
}



15. Select options from project settings


16. Check the iOS settings and make sure it looks same as screenshot below 

 

17. Provision the Xamarin application to create a build - https://developer.xamarin.com/guides/ios/getting_started/installation/device_provisioning/