Xamarin iOS SDK

Integrating Pushwoosh SDK into your Xamarin iOS project

iOS Simulator can neither subscribe to nor receive push notifications.

To integrate Pushwoosh with your Xamarin iOS application:

1. Add Pushwoosh.Xamarin.iOS nuget package to your solution.

2. In your project, open AppDelegate.cs and connect Pushwoosh by adding the using Pushwoosh line.

3. In your Info.plist add Pushwoosh_APPID key with your Pushwoosh Application ID string value.

4. Organize the following imports:

  • using Pushwoosh;
  • using UserNotifications;

5. Add the methods below to AppDelegate class:

public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
{
    PushNotificationManager.PushManager.HandlePushRegistration (deviceToken);
}
 
public override void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error)
{
    PushNotificationManager.PushManager.HandlePushRegistrationFailure (error);
}
 
public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo)        
{
     PushNotificationManager.PushManager.HandlePushReceived (userInfo);
}

6. Add the code below to public override bool FinishedLaunching(UIApplication app, NSDictionary launchOptions) method:

PushNotificationManager pushmanager = PushNotificationManager.PushManager;
pushmanager.Delegate = this;
UNUserNotificationCenter.Current.Delegate = pushmanager.notificationCenterDelegate;
 
if (options != null) {
     if (options.ContainsKey (UIApplication.LaunchOptionsRemoteNotificationKey)) { 
       pushmanager.HandlePushReceived(options);
     }
}
 
pushmanager.RegisterForPushNotifications();

7. To use Geozones, add the line below to the same method:

pushmanager.StartLocationTracking();

Xamarin iOS SDK

Integrating Pushwoosh SDK into your Xamarin iOS project