Push Notifications

See the iOS integration instructions for information about setting up your application with push and storing your credentials on our server.

Integration

Requesting Push Permissions

Set up push permissions by adding the following code to the FinishedLaunching section of your AppDelegate.cs:

1
2
3
UIUserNotificationSettings settings = UIUserNotificationSettings.GetSettingsForTypes (UIUserNotificationType.Badge | UIUserNotificationType.Alert | UIUserNotificationType.Sound, null);
UIApplication.SharedApplication.RegisterForRemoteNotifications ();
UIApplication.SharedApplication.RegisterUserNotificationSettings (settings);

If you’ve implemented a custom push opt-in prompt, make sure that you’re calling the above code EVERY time the app runs after they grant push permissions to your app. Apps need to reregister with APNs as device tokens can change arbitrarily.

Registering Push Tokens

Register for your push tokens by adding the following code in the RegisteredForRemoteNotifications method of your AppDelegate.cs:

1
Appboy.SharedInstance ().RegisterPushToken (deviceToken.ToString ());

Enabling Push Analytics

Enable open tracking on push notifications by adding the following code to the DidReceiveRemoteNotification method of your AppDelegate.cs:

1
2
3
4
public override void DidReceiveRemoteNotification (UIApplication application, NSDictionary userInfo, Action<UIBackgroundFetchResult> completionHandler)
  {
    Appboy.SharedInstance ().RegisterApplicationWithFetchCompletionHandler(application, userInfo, completionHandler);
  }

Badge Count

If badge counts are enabled, Braze will display a badge when a customer has unread notifications. By default, this number is 1. Braze will only clear the badge count when the app is opened directly from an Braze push notification. To clear the badge count, you can refer to the Xamarin documentation and use the following code:

Xamarin C#

1
UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
WAS THIS PAGE HELPFUL?