资源简介
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源码
- 下一篇:京东商品爬虫
相关资源
- hp bios 升级软件
- Phoenix BIOS 解压程序 phcomp
- 蓝宝石578bios
- 迪兰战神RX580 8G 原版静音bios
- 盈通RX584-游戏高手-三星显存 BIOS
- 盈通rx580 2304 8g大地之神bios
- ios应用源码之房贷计算器改进 201812
- ios应用源码之分享到facebook的api 2018
- iOS程序设计_猜拳游戏制作_艾孜尔江
- 映泰RX584矿BIOS
- ios-高仿网易新闻.zip
- 迪兰恒进 战神 RX580 8G 原版BIOS
- OC编写计算器
- Xcode9.4
- 1150-600 rx584 samsung.rom 白牌rx584三星显存
-
ob
jective-c实现简单计算器 - 蓝天780M清凉版BIOS
- ios 高仿网易新闻客户端
- dos和bios开发讲解.pdf
- 盈通584三星显存bios.rom
- ios简易计算器
- swift-豆瓣电台源代码、以及图片资源
- FlashBios+(WIN下消除BIOS密码)
- sg-dma dma传输在nios中实现
- 解决ipa导出的png无法在windows 下查看的
- iOS CoreData实现简易的成绩管理系统
- IOS简易的成绩管理系统
- IOS计算器源码
- 关东升《iOS开发指南》第5版链接
- TDOA positioning in NLOS scenarios by particle
评论
共有 条评论