CocoaPods trunk is moving to be read-only. Read more on the blog, there are 9 months to go.
The Quality Promised Information Deliverer.
Quick Feed.
Mobile SDK for MQTT push library. Now you can deliver any message without worries.
You can look into more detailed documents in here.
You can use CocoaPods to install QpidSDK by adding it to your Podfile:
platform :ios, '8.0'
use_frameworks!
pod 'QpidSDK'To get started with it, import QpidSDK wherever you want to play or record.
import QpidSDK@import <QpidSDK/QpidSDK.h>QpidSDK.framework in your project.icucore and sqlite3 and zlib library in your project.Info.plistSome of pre-define value should be configured in Plist file.
<key>Qpid Configuration</key>
<dict>
<key>API Key</key>
<string>585a0b3d6ccb780de407d2ef</string>
<key>API Token</key>
<string>336f3d2a-44d6-49f3-8fbc-22b37953ad65</string>
<key>Base URL</key>
<string>tcp://14.63.173.15:1883</string>
<key>Debug Level</key>
<integer>5</integer>
<key>Debug on Console</key>
<true/>
<key>Debug on File</key>
<true/>
<key>Debug on Screen</key>
<true/>
</dict>String value. The API key that is provided which specified your app.
String value. The token that is provided to use the API.
String value. The URL which server you want to connect.
Integer value. 0~5 log level. 0 is off and 5 is verbose. If set as Off, below values are ignored.
Boolean value. Whether you want to print log on debug console.
Boolean value. Whether you want to print log on file.
Boolean value. Whether you want to print log on screen.
Allow all, or the URL we provided. This is needed to be able to make a network connection.
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>More info : Document / Video (WWDC 2015-711)
SDK will work in background cause of some particular reasons.
<key>UIBackgroundModes</key>
<array>
<string>fetch</string>
<string>remote-notification</string>
</array>This SDK will cover the non-reached message by fetching in background.
This SDK will try to connect to the server when it's necessary via remote-notification
You need to implement life cycle methods in AppDelegate of your app.
When the app launched, this method will be called. It's best place to initialize SDK and deliver the options.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[Qpid requestNotificationAuthorizationWithDelegate:self];
[Qpid setDelegate:self];
[Qpid handlingLaunchWithOptions:launchOptions];
return YES;
}When the app has registered for remote notification, this method will be called. As long as the SDK is Enabled this is where connection established.
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
[Qpid setPushToken:deviceToken];
}When the fetch of UIBackgroundModes started to work, this method will be called. SDK will also fetch undelivered messages.
- (void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
[Qpid handlingPerformFetchWithCompletionHandler:^(UIBackgroundFetchResult qpidResult) {
// do your thing here and call `completionHandler`
UIBackgroundFetchResult myResult = UIBackgroundFetchResultNoData; // your result..
completionHandler(MIN(qpidResult, myResult));
}];
}When there is no established connection with server, server will try to connect via this method. This method will get called when the app got push notifications.
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
if (![Qpid handlingRemoteNotification:userInfo fetchCompletionHandler:completionHandler]) {
// It's not from Qpid.
completionHandler(UIBackgroundFetchResultNewData); // or UIBackgroundFetchResultNoData or UIBackgroundFetchResultFailed
}
}All the notifications and other info will be delivered from the delegate below. You must call -complete method after you handled the event.
Determine how many messages app will handle a time.
- (NSUInteger)maxConcurrentMessageCount
{
return UINT_MAX;
}This method will deliver the message. Your magic code should be in this delegate. You must call -complete method after you handled the event.
- (void)didGetNewMessage:(QPMessage *)message
{
NSLog(@"message : %@", message);
[QPUIManager presentAlertFromMessage:message onWindow:self.window dismissHandler:nil];
}This method will be called when you complete the message. You can do post action here.
- (void)didGetNewMessage:(QPMessage *)message
{
NSLog(@"message : %@", message);
[QPUIManager presentAlertFromMessage:message onWindow:self.window dismissHandler:nil];
}Any errors that might help you to find issues will be delivered with this method.
- (void)didFailedWithError:(NSError *)error
{
NSLog(@"error : %@", error);
}didCompleteMessage: delegate.shouldPostNotificationMessage delegate.MJ – [email protected]