Skip to content

Instantly share code, notes, and snippets.

@pierceboggan
Created June 18, 2013 20:39
Show Gist options
  • Save pierceboggan/5809145 to your computer and use it in GitHub Desktop.
Save pierceboggan/5809145 to your computer and use it in GitHub Desktop.
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