Skip to content

Instantly share code, notes, and snippets.

@matzew

matzew/ios.md Secret

Last active December 21, 2015 01:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matzew/207bf5aaa227c74e61f0 to your computer and use it in GitHub Desktop.
Save matzew/207bf5aaa227c74e61f0 to your computer and use it in GitHub Desktop.

What's new in AeroGear iOS ?

The 1.2.0 version of aerogear-ios contains only one minor change, the deprecation of the login: password: success: failure method.

APNs support

With the August release the entire AeroGear focus was around adding Push Notification. Two servers (see UnifiedPush Server Blog and SimplePush server blog for more details) have been written and we added support to our client platforms (see here for Android/JS) as well!

For the iOS library that obviously means adding support for the Apple Push Notification Service.

Stay standard!

For receiving APNs push notifications there are no extra APIs introduced. The standard Apple APIs work with the AeroGear UnifiedPush server and the our AeroGear Push SDK. For instance, you can use the existing delegate for receiving remote notifications while the application is running, like:

- (void)application:(UIApplication *)application 
  didReceiveRemoteNotification:(NSDictionary *)userInfo {
    // extract desired value from the dictionary...
}

Device Registration

In order to be able to receive push notifications you need to register the iOS device token with a server. The same is true when using the AeroGear UnifiedPush server. The SDK helps you to perform an easy registration:

- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {

  AGDeviceRegistration *registration = 
    [[AGDeviceRegistration alloc] initWithServerURL:
     [NSURL URLWithString:@"http://YOUR_SERVER/ag-push/"]];

  [registration registerWithClientInfo:^(id<AGClientDeviceInformation> clientInfo) {

    // required fields
    [clientInfo setDeviceToken:deviceToken];
    [clientInfo setVariantID:@"YOUR IOS VARIANT ID"];
    [clientInfo setVariantSecret:@"YOUR IOS VARIANT SECRET"];

    // --optional config--
    UIDevice *currentDevice = [UIDevice currentDevice];
    [clientInfo setOperatingSystem:[currentDevice systemName]];
    [clientInfo setOsVersion:[currentDevice systemVersion]];
    [clientInfo setDeviceType: [currentDevice model]];
	} success:^() {
      NSLog(@"PushEE registration worked");
	} failure:^(NSError *error) {
      NSLog(@"PushEE registration Error: %@", error);
  }];
}

All you need is simply providing the URL of the UnifiedPush server, the deviceToken, the variantID and the variantSecret.

In the UnifiedPush server when you create an iOS Variant for a PushApplication, the AdminUI does provide the information about the variantID and the variantSecret:

Xcode Template

Our AeroGear Xcode Template has been updated and supports the new Push SDK as well:

Tutorial

Getting started with the APNs is hard, especially with setting up all the Apple related things, like certificates or provisioning profiles. We have create a tutorial that explains the entire workflow, of using the AeroGear UnifiedPush server and the iOS SDK, explained with a simplified demo application.

Check it out!

Feedback welcome

Reach out to us on IRC or our mailing list. Bugs and feature requests are always welcome in our JIRA instance.

Enjoy !

@cvasilak
Copy link

small typos:

s/obivously/obviously
s/intance/instance

@corinnekrych
Copy link

  1. s/and the our little Push SDK/and your simple Push SDK/

=> I don't really like the 'little' adjective, personal view though

  1. obivously

=> spelling

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment