資源簡介
oc開發,服務器端啟動mqtt服務端,手機端使用mqtt客戶端,動態獲取推送消息,參考demo

代碼片段和文件信息
//
//??ForegroundReconnection.m
//??MQTTClient
//
//??Created?by?Josip?Cavar?on?22/08/2017.
//??Copyright???2017?Christoph?Krey.?All?rights?reserved.
//
#import?“ForegroundReconnection.h“
#if?TARGET_OS_IPHONE?==?1
#import?“MQTTSessionManager.h“
#import?
@interface?ForegroundReconnection?()
@property?(nonatomic)?UIBackgroundTaskIdentifier?backgroundTask;
@end
@implementation?ForegroundReconnection
-?(instancetype)initWithMQTTSessionManager:(MQTTSessionManager?*)manager?{
????self?=?[super?init];
????self.sessionManager?=?manager;
????self.backgroundTask?=?UIBackgroundTaskInvalid;
????
????NSNotificationCenter?*defaultCenter?=?[NSNotificationCenter?defaultCenter];
????
????[defaultCenter?addObserver:self
??????????????????????selector:@selector(appWillResignActive)
??????????????????????????name:UIApplicationWillResignActiveNotification
????????????????????????object:nil];
????
????[defaultCenter?addObserver:self
??????????????????????selector:@selector(appDidEnterBackground)
??????????????????????????name:UIApplicationDidEnterBackgroundNotification
????????????????????????object:nil];
????
????[defaultCenter?addObserver:self
??????????????????????selector:@selector(appDidBecomeActive)
??????????????????????????name:UIApplicationDidBecomeActiveNotification
????????????????????????object:nil];
????return?self;
}
-?(void)dealloc?{
????NSNotificationCenter?*defaultCenter?=?[NSNotificationCenter?defaultCenter];
????[defaultCenter?removeObserver:self?name:UIApplicationWillResignActiveNotification?object:nil];
????[defaultCenter?removeObserver:self?name:UIApplicationDidEnterBackgroundNotification?object:nil];
????[defaultCenter?removeObserver:self?name:UIApplicationDidBecomeActiveNotification?object:nil];
}
-?(void)appWillResignActive?{
????[self.sessionManager?disconnectWithDisconnectHandler:nil];
}
-?(void)appDidEnterBackground?{
????if?(!self.sessionManager.requiresTearDown)?{
????????//?we?don‘t?want?to?tear?down?session?as?it‘s?already?closed
????????return;
????}
????
????__weak?typeof(self)?weakSelf?=?self;
????self.backgroundTask?=?[[UIApplication?sharedApplication]?beginBackgroundTaskWithExpirationHandler:^{
????????__strong?typeof(weakSelf)?strongSelf?=?weakSelf;
????????[strongSelf?endBackgroundTask];
????}];
}
-?(void)appDidBecomeActive?{
????[self.sessionManager?connectToLast:nil];
}
-?(void)endBackgroundTask?{
????if?(self.backgroundTask)?{
????????[[UIApplication?sharedApplication]?endBackgroundTask:self.backgroundTask];
????????self.backgroundTask?=?UIBackgroundTaskInvalid;
????}
}
@end
#endif
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-02-16?09:43??MQTT-Client-fr
?????文件?????????220??2018-02-16?09:43??MQTT-Client-fr
?????文件?????????317??2018-02-16?09:43??MQTT-Client-fr
?????文件???????10497??2018-02-16?09:43??MQTT-Client-fr
?????文件???????12922??2018-02-16?09:43??MQTT-Client-fr
?????文件????????4506??2018-02-16?09:43??MQTT-Client-fr
?????目錄???????????0??2018-02-16?09:43??MQTT-Client-fr
?????目錄???????????0??2018-02-16?09:43??MQTT-Client-fr
?????文件??????135441??2018-02-16?09:43??MQTT-Client-fr
?????目錄???????????0??2018-02-16?09:43??MQTT-Client-fr
?????文件?????????155??2018-02-16?09:43??MQTT-Client-fr
?????目錄???????????0??2018-02-16?09:43??MQTT-Client-fr
?????目錄???????????0??2018-02-16?09:43??MQTT-Client-fr
?????文件????????3746??2018-02-16?09:43??MQTT-Client-fr
?????文件????????3758??2018-02-16?09:43??MQTT-Client-fr
?????文件????????3752??2018-02-16?09:43??MQTT-Client-fr
?????目錄???????????0??2018-02-16?09:43??MQTT-Client-fr
?????文件?????????228??2018-02-16?09:43??MQTT-Client-fr
?????目錄???????????0??2018-02-16?09:43??MQTT-Client-fr
?????文件????????1677??2018-02-16?09:43??MQTT-Client-fr
?????目錄???????????0??2018-02-16?09:43??MQTT-Client-fr
?????文件??????101124??2018-02-16?09:43??MQTT-Client-fr
?????文件?????????444??2018-02-16?09:43??MQTT-Client-fr
?????文件????????2576??2018-02-16?09:43??MQTT-Client-fr
?????文件?????????496??2018-02-16?09:43??MQTT-Client-fr
?????文件????????1691??2018-02-16?09:43??MQTT-Client-fr
?????文件????????1009??2018-02-16?09:43??MQTT-Client-fr
?????文件????????2710??2018-02-16?09:43??MQTT-Client-fr
?????文件?????????957??2018-02-16?09:43??MQTT-Client-fr
?????文件????????3580??2018-02-16?09:43??MQTT-Client-fr
?????文件????????2522??2018-02-16?09:43??MQTT-Client-fr
............此處省略203個文件信息
- 上一篇:雷霆戰機II FLASH源碼
- 下一篇:京東商品爬蟲
評論
共有 條評論