质量保证信息传递者。
快速推送。
适用于 MQTT 推送库的移动 SDK。现在您可以无忧地传递任何消息。
您可以在这里查看更详细的文档。
您可以使用 CocoaPods 通过将其添加到您的 Podfile
来安装 QpidSDK
platform :ios, '8.0'
use_frameworks!
pod 'QpidSDK'
要开始使用它,在您想播放或录制的位置导入 QpidSDK
import QpidSDK
@import <QpidSDK/QpidSDK.h>
QpidSDK.framework
拖放到您的项目中。icucore
、sqlite3
和 zlib
库添加到您的项目中。Info.plist
中设置一些预定义值应在 Plist
文件中配置。
<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>
字符串值。提供的 API 密钥指定了您的应用程序。
字符串值。提供的用于使用 API 的令牌。
字符串值。您要连接的服务器 URL。
整数值。0~5 级日志。0 是 关,5 是 详细。如果设置为关,则忽略以下值。
布尔值。是否要在调试控制台打印日志。
布尔值。是否要在文件中打印日志。
布尔值。是否要在屏幕上打印日志。
允许所有,或我们提供的 URL。这是建立网络连接所需的。
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
更多信息:文档 / 视频(WWDC 2015-711)
由于某些特定原因,SDK 将在后台运行。
<key>UIBackgroundModes</key>
<array>
<string>fetch</string>
<string>remote-notification</string>
</array>
此 SDK 将通过后台获取覆盖到的未到达消息。
此 SDK 将在必要时通过 remote-notification
尝试连接到服务器。
您需要在应用程序的 AppDelegate 中实现生命周期方法。
当应用程序启动时,此方法将被调用。这是初始化 SDK 和传递选项的最佳位置。
- (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;
}
当应用程序已注册远程通知时,此方法将被调用。只要 SDK 是 Enabled
,这是建立连接的地方。
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
[Qpid setPushToken:deviceToken];
}
当UIBackgroundModes
的fetch
开始工作,此方法将被调用。SDK还将获取未发送的消息。
- (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));
}];
}
当没有与服务器建立连接时,服务器将尝试通过此方法连接。应用程序收到推送通知时,此方法将被调用。
- (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
}
}
所有通知和其他信息将通过以下代理传达。 您必须在处理完事件后调用-complete
方法。
确定应用程序一次性处理的请求数量。
- (NSUInteger)maxConcurrentMessageCount
{
return UINT_MAX;
}
此方法将通过消息。您的神奇代码应在此代理中。 您必须在处理完事件后调用-complete
方法。
- (void)didGetNewMessage:(QPMessage *)message
{
NSLog(@"message : %@", message);
[QPUIManager presentAlertFromMessage:message onWindow:self.window dismissHandler:nil];
}
当您完成消息时,将调用此方法。您可以在其中执行后续操作。
- (void)didGetNewMessage:(QPMessage *)message
{
NSLog(@"message : %@", message);
[QPUIManager presentAlertFromMessage:message onWindow:self.window dismissHandler:nil];
}
可能会帮助您找到问题的任何错误将通过此方法传达。
- (void)didFailedWithError:(NSError *)error
{
NSLog(@"error : %@", error);
}
didCompleteMessage:
代理。shouldPostNotificationMessage
代理。MJ – [email protected]