TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | Apache 2 |
ReleasedLast Release | Oct 2017 |
Maintained by corinne krych, Julio Cesar, Daniel Passos, Massimiliano Ziccardi.
iOS Push Notification Registration SDK for the AeroGear UnifiedPush Server
A small and handy library that helps to register iOS applications with the AeroGear UnifiedPush Server.
Project Info | |
---|---|
License: | Apache License, Version 2.0 |
Build: | CocoaPods |
Documentation: | http://aerogear.org/ios/ |
Issue tracker: | https://issues.jboss.org/browse/AGIOS |
Mailing lists: | aerogear-users (subscribe) |
aerogear-dev (subscribe) |
To build the library simply run the build script:
build.sh
The build script will generate a buid folder containing an universal static lib and a framework, sources and documentation are also packaged.
The push-sdk.xcodeproject contains two framework targets pushsdk
to build dynamic framework supported from iOS8 and used when runnning unit tests and push-sdk
to building static framework supported from iOS7.
NOTE Dynamic framework name should not contain -
symbols.
You have different options to add aerogear-push-registration library to your project.
After you have built the library (see "Building the library" section), from aerogear-ios-push directory, run the copy command:
cp -R build/AeroGearPush-iphoneuniversal/* ../<YourProjectFolder>
Go to root node in the project navigator, and select the target. Select Build Settings, and locate the Header Search Paths setting in the list. Double click on the Header Search Paths item, and a popover will appear. Click the + button, and enter the following:
$SOURCE_ROOT/include
Select the Build Phases tab, and expand the Link Binary With Libraries section and add libpush-sdk-X.X.X.a
Click on the Build Settings tab, and locate the Other linker Flags setting and add -ObjC
NOTE: Please refer to the 64 bits note above.
After you have built the framework (see "Building the library" section), from aerogear-ios-push directory, run the copy command:
cp -R build/AeroGearPush-framework/AeroGearPush.framework ../<YourProjectFolder>
Go to targets. In Build Phases / Link Binary With Libraries add AeroGearPush.framework
#import <AeroGearPush/AeroGearPush.h>
You can use aerogear-push-helloworld as an example of project using aerogear-push-ios-registration as a framework dependency.
NOTE: Please refer to the 64 bits note above.
- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
AGDeviceRegistration *registration =
[[AGDeviceRegistration alloc] initWithServerURL:
[NSURL URLWithString:@"http://YOUR_SERVER/ag-push/"]];
[registration registerWithClientInfo:^(id<AGClientDeviceInformation> clientInfo) {
[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(@"UnifiedPush Server registration worked");
} failure:^(NSError *error) {
NSLog(@"UnifiedPush Server registration Error: %@", error);
}];
}
In the ppDelegate.m
file:
- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
AGDeviceRegistration *registration =
[[AGDeviceRegistration alloc] init];
[registration registerWithClientInfo:^(id<AGClientDeviceInformation> clientInfo) {
[clientInfo setDeviceToken:deviceToken];
UIDevice *currentDevice = [UIDevice currentDevice];
[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.
There are no extra hooks for receiving notifications with the AeroGear library. 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...
}
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.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[AGPushAnalytics sendMetricsWhenAppLaunched:launchOptions];
return YES;
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler {
[AGPushAnalytics sendMetricsWhenAppAwoken:application.applicationState userInfo: userInfo];
}
For more information checkout our tutorial.
For more details about the current release, please consult our documentation.
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
Join our user mailing list for any questions or help! We really hope you enjoy app development with AeroGear!
If you found a bug please create a ticket for us on Jira with some steps to reproduce it.