Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Urban Airship setup for Xamarin.iOS.
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
window = new UIWindow (UIScreen.MainScreen.Bounds);
viewController = new UrbanAirshipTestViewController ();
window.RootViewController = viewController;
window.MakeKeyAndVisible ();
UAPush.Shared.RegisterForRemoteNotificationTypes(UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound);
var takeOffOptions = new NSMutableDictionary ();
options = new NSDictionary ();
takeOffOptions.SetValueForKey (options, new NSString ("UAirshipTakeOffOptionsLaunchOptionsKey"));
UAPush.Shared.ResetBadge ();
UAirship.TakeOff (takeOffOptions);
return true;
}
public override void ReceivedRemoteNotification (UIApplication application, NSDictionary userInfo)
{
var message = (NSString) userInfo.ObjectForKey (new NSString ("aps")).ValueForKey(new NSString("alert"));
var alert = new UIAlertView("Notification", message, null, "Okay", null);
alert.Show ();
}
public override void WillTerminate (UIApplication application)
{
UAirship.Land ();
}
public override void RegisteredForRemoteNotifications (UIApplication application, NSData deviceToken)
{
UAPush.Shared.RegisterDeviceToken (deviceToken);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment