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: | Swift 4 |
Documentation: | http://aerogear.org/ios/ |
Issue tracker: | https://issues.jboss.org/browse/AGIOS |
Mailing lists: | aerogear-users (subscribe) |
aerogear-dev (subscribe) |
- Register (Programmatically and plist) on AeroGear UnifiedPush Server
- Send metrics to AeroGear UnifiedPush Server
In your Podfile
add:
pod 'AeroGearPush-Sw'
and then:
pod install
to install your dependencies
// setup registration
let registration = DeviceRegistration(serverURL: URL(string: "<#AeroGear UnifiedPush Server URL#>")!)
// attempt to register
registration.register(
clientInfo: { (clientDevice: ClientDeviceInformation!) in
// setup configuration
clientDevice.deviceToken = deviceToken
clientDevice.variantID = "<# Variant Id #>"
clientDevice.variantSecret = "<# Variant Secret #>"
// apply the token, to identify THIS device
let currentDevice = UIDevice()
// -- optional config --
// set some 'useful' hardware information params
clientDevice.operatingSystem = currentDevice.systemName
clientDevice.osVersion = currentDevice.systemVersion
clientDevice.deviceType = currentDevice.model
},
success: {
print("UnifiedPush Server registration succeeded")
},
failure: { (error: Error!) in
print("failed to register, error: \(error.localizedDescription)")
}
)
// setup registration
let registration = DeviceRegistration(config: "pushconfig")
// attempt to register
registration.register(
clientInfo: { (clientDevice: ClientDeviceInformation!) in
// setup configuration
clientDevice.deviceToken = deviceToken
// apply the token, to identify THIS device
let currentDevice = UIDevice()
// set some 'useful' hardware information params
clientDevice.operatingSystem = currentDevice.systemName
clientDevice.osVersion = currentDevice.systemVersion
clientDevice.deviceType = currentDevice.model
},
success: {
print("UnifiedPush Server registration succeeded")
},
failure: { (error: Error!) in
print("failed to register, error: \(error.localizedDescription)")
}
)
In your application, create a pushconfig.plist
file, and 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.
If you are interested in monitoring how a push message relates to the usage of your app, you can use metrics. Those metrics are displayed in the AeroGear UnifiedPush Server's console.
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Send metrics when app is launched due to push notification
PushAnalytics.sendMetricsWhenAppLaunched(launchOptions: launchOptions)
return true
}
func application(_ application: UIApplication,
didReceiveRemoteNotification userInfo: [AnyHashable: Any],
fetchCompletionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
// Send metrics when app is launched due to push notification
PushAnalytics.sendMetricsWhenAppAwoken(applicationState: application.applicationState, userInfo: userInfo)
// ... Some stuffs ...
// No additional data to fetch
fetchCompletionHandler(UIBackgroundFetchResult.noData)
}
For more details about that please consult our documentation.
Take a look in our demo apps:
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.