Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/399.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何在后台运行Mosquetto_Ios_Swift_Mosquitto - Fatal编程技术网

Ios 如何在后台运行Mosquetto

Ios 如何在后台运行Mosquetto,ios,swift,mosquitto,Ios,Swift,Mosquitto,我在使用libmosquitto开发iOS应用程序时遇到一些问题 在我的代码中 AppDelegate.swift import UIKit @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate, MosquittoClientDelegate{ var window: UIWindow? var client: MosquittoClient? func didPublis

我在使用libmosquitto开发iOS应用程序时遇到一些问题

在我的代码中 AppDelegate.swift

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, MosquittoClientDelegate{

    var window: UIWindow?
    var client: MosquittoClient?

    func didPublish(messageId: UInt) {
        println( "didPublish \(messageId)" )
    }
    func didReceiveMessage(mosq_msg: MosquittoMessage!) {
        println( "didReceiveMessage [ \(mosq_msg.mid)-\(mosq_msg.topic) ] \(mosq_msg.payload)" )
    }
    func didDisconnect() {
        println( "didDisconnect" )
    }
    func didConnect(code: UInt) {
        println( "didConnect \(code)" )
        if code == UInt(MOSQ_ERR_SUCCESS.value){
            client?.subscribe("sample", withQos: 1)
        }
    }
    func didSubscribe(messageId: UInt, grantedQos qos: [AnyObject]!) {
        println( "didSubscribe" )
    }
    func didUnsubscribe(messageId: UInt) {
        println( "didUnsubscribe \(messageId)" )
    }

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {        
        client = MosquittoClient(clientId: "qq")
        client?.host = "stick.coffee"
        client?.port = 1883
        client?.delegate = self
        client?.connect()
        return true
    }
}
这和我想的一样,除了退出应用程序

即使应用程序已退出,我也希望收到消息

我发现有一些背景模式

  • 音频和播放
  • 位置更新
  • IP语音
  • 报摊下载
  • 外部附件通信
  • 使用蓝牙和蓝牙配件
  • 作为蓝牙耳机配件
  • 后台提取
  • 远程通知
什么是最适合我的模式? 或者这个存根有什么例子吗?

是的, 我发现没有后台运行的方法

但如果不需要上传AppleStore,voip可以在后台运行


因此,我使用voip实现。

与您的问题无关,但您能否建议我在哪里可以获得iOS版的LibmosQuito?我下载了文件并放在一个文件夹中,但其中没有With_TLS标志。