gpt4 book ai didi

ios - Sinch 框架(Objective C)和 Swift 不兼容

转载 作者:行者123 更新时间:2023-11-29 01:24:45 25 4
gpt4 key购买 nike

我正在使用用 Objective C 编写的 Sinch SDK ( link)。

但我正在制作一个 Swift 应用程序。我创建了桥头并在 View Controller 中添加了一些基本功能:

import UIKit

class ViewController: UIViewController, SINMessageClientDelegate {

override func viewDidLoad() {
super.viewDidLoad()

initializeSinch()
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}

func initializeSinch()
{
// Instantiate a Sinch client object
let sinchClient = Sinch.clientWithApplicationKey("xxxxxxxxxxxx", applicationSecret: "xxxxxxxxxx", environmentHost: "sandbox.sinch.com", userId: "user1")
sinchClient.setSupportMessaging(true)
sinchClient.start()

let messageClient = sinchClient.messageClient()

let message = SINOutgoingMessage(recipient: "user2", text: "Test 123, test 123")
messageClient.sendMessage(message)
}

// Tells the delegate that a message has been received.
func messageClient(messageClient: SINMessageClient, didReceiveIncomingMessage message: SINMessage) {
// Present a Local Notification if app is in background
if UIApplication.sharedApplication().applicationState == .Background {
var notification: UILocalNotification = UILocalNotification()
notification.alertBody = "Message from \(message.recipientIds[0])"
UIApplication.sharedApplication().presentLocalNotificationNow(notification)
}
else {
// Update UI in-app
}

}

// Tells the delegate that a message for a specific recipient has been sent by the local user.
func messageSent(message: SINMessage, recipientId: String) {
// var a = 1
}
//
// Tells the delegate that a message has been delivered (to a particular recipient).
func messageDelivered(info: SINMessageDeliveryInfo) {
// var a = 1
}

func messageFailed(message: SINMessage, info messageFailureInfo: SINMessageFailureInfo) {
// var a = 1
}

}

这是错误的样子。 Error log

有人可以建议我如何解决这个问题吗?

最佳答案

您是否添加了所有必要的框架和链接器标志?

AudioToolbox.framework
AVFoundation.framework
Security.framework

需要添加一些额外的链接器标志。在应用程序目标的“build设置” Pane 中,设置以下内容:

Other Linker Flags -> -ObjC -Xlinker -lc++

https://www.sinch.com/docs/voice/ios/

关于ios - Sinch 框架(Objective C)和 Swift 不兼容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34144346/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com