AeroGearPush-ObjC 2.0.1

AeroGearPush-ObjC 2.0.1

Maintained by weili, Massimiliano Ziccardi.



  • By
  • Red Hat, Inc.

AeroGear iOS Push

Maintenance circle-ci License GitHub release CocoaPods Platform

A handy library that helps to register iOS applications with the AeroGear UnifiedPush Server.

Project Info
License: Apache License, Version 2.0
Build: CocoaPods
Languague: Objective-C
Documentation: http://aerogear.org/ios/
Issue tracker: https://issues.jboss.org/browse/AGIOS
Mailing lists: aerogear-users (subscribe)
aerogear-dev (subscribe)

Table of Content

Features

Installation

CocoaPods

In your Podfile add:

pod 'AeroGearPush'

and then:

pod install

to install your dependencies

Usage

Push registration (Programmatically)

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

// attempt to register
[registration registerWithClientInfo:^(id <AGClientDeviceInformation> clientInfo) {

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

    // apply the token, to identify THIS device
    UIDevice *currentDevice = [UIDevice currentDevice];

    // set some 'useful' hardware information params
    [clientInfo setOperatingSystem:[currentDevice systemName]];
    [clientInfo setOsVersion:[currentDevice systemVersion]];
    [clientInfo setDeviceType:[currentDevice model]];
}                            success:^() {
    NSLog(@"UnifiedPush Server registration worked");
}                            failure:^(NSError *error) {
    NSLog(@"UnifiedPush Server registration Error: %@", error);
}];

Push registration (plist)

// setup registration
AGDeviceRegistration *registration = [[AGDeviceRegistration alloc] init];

// attempt to register
[registration registerWithClientInfo:^(id <AGClientDeviceInformation> clientInfo) {

    // setup configuration
    [clientInfo setDeviceToken:deviceToken];

    // apply the token, to identify THIS device
    UIDevice *currentDevice = [UIDevice currentDevice];

    // set some 'useful' hardware information params
    [clientInfo setOperatingSystem:[currentDevice systemName]];
    [clientInfo setOsVersion:[currentDevice systemVersion]];
    [clientInfo setDeviceType:[currentDevice model]];
}                            success:^() {
    NSLog(@"UnifiedPush Server registration worked");
}                            failure:^(NSError *error) {
    NSLog(@"UnifiedPush Server registration Error: %@", error);
}];

In your application info.plist, add the following properties:

<plist version="1.0">
<dict>
  <key>serverURL</key>
  <string><# URL of the running AeroGear UnifiedPush Server #></string>
  <key>variantID</key>
  <string><# Variant Id #></string>
  <key>variantSecret</key>
  <string><# Variant Secret #></string>
</dict>
</plist>

NOTE: If your UPS server installation uses a self-signed certificate, you can find a quick solution on how to enable support on our troubleshooting page, as well as links for further information on how to properly enable it on your iOS production applications.

Push analytics

If you are interested in monitoring how a push message relates to the usage of your app, you can use metrics. Those emtrics are displayed in the AeroGear UnifiedPush Server's console.

Metrics when app is launched

- (BOOL)          application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [AGPushAnalytics sendMetricsWhenAppLaunched:launchOptions];
    return YES;
}

Metrics when the app is brought from background to foreground

- (void)   application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler {
    [AGPushAnalytics sendMetricsWhenAppAwoken:application.applicationState userInfo:userInfo];
}

Documentation

For more details about that please consult our documentation.

Development

If you would like to help develop AeroGear you can join our developer's mailing list, join #aerogear on Freenode, or shout at us on Twitter @aerogears.

Also takes some time and skim the contributor guide

Questions?

Join our user mailing list for any questions or help! We really hope you enjoy app development with AeroGear!

Found a bug?

If you found a bug please create a ticket for us on Jira with some steps to reproduce it.