hello,
I'm trying to work with PubNub, when I "installed" the SDK and run the project, it was written "Thread 1: EXC_BAD_INSTRUCTION (code=EXC_l386_INPOV, subcode=0x0)"
that's my ViewController.swift:
import UIKit
import PubNub
class UpdatesViewController: UIViewController {
var client: PubNub!
override func viewDidLoad() {
super.viewDidLoad()
/
let configuration = PNConfiguration(publishKey: "demo", subscribeKey: "demo")
/*
Subscription process results arrive to listener which should adopt to PNObjectEventListener protocol
and registered using:
*/
self.client.addListener(self as! PNObjectEventListener)
self.client.subscribeToChannels(["my_channel1"], withPresence: false)
/
func client(_ client: PubNub, didReceiveMessage message: PNMessageResult) {
/
if message.data.channel != message.data.subscription {
/
}
else {
/
}
print("Received message: \(message.data.message) on channel \(message.data.channel) " +
"at \(message.data.timetoken)")
}
/
func client(_ client: PubNub, didReceive status: PNStatus) {
if status.operation == .subscribeOperation {
/
if status.category == .PNConnectedCategory || status.category == .PNReconnectedCategory {
let subscribeStatus: PNSubscribeStatus = status as! PNSubscribeStatus
if subscribeStatus.category == .PNConnectedCategory {
/
}
else {
/*
This usually occurs if subscribe temporarily fails but reconnects. This means there was
an error but there is no longer any issue.
*/
}
}
else if status.category == .PNUnexpectedDisconnectCategory {
/*
This is usually an issue with the internet connection, this is an error, handle
appropriately retry will be called automatically.
*/
}
/
/
else {
let errorStatus: PNErrorStatus = status as! PNErrorStatus
if errorStatus.category == .PNAccessDeniedCategory {
/*
This means that PAM does allow this client to subscribe to this channel and channel group
configuration. This is another explicit error.
*/
}
else {
/*
More errors can be directly specified by creating explicit cases for other error categories
of `PNStatusCategory` such as: `PNDecryptionErrorCategory`,
`PNMalformedFilterExpressionCategory`, `PNMalformedResponseCategory`, `PNTimeoutCategory`
or `PNNetworkIssuesCategory`
*/
}
}
}
else if status.operation == .unsubscribeOperation {
if status.category == .PNDisconnectedCategory {
/*
This is the expected category for an unsubscribe. This means there was no error in
unsubscribing from everything.
*/
}
}
else if status.operation == .heartbeatOperation {
/*
Heartbeat operations can in fact have errors, so it is important to check first for an error.
For more information on how to configure heartbeat notifications through the status
PNObjectEventListener callback, consult */
if !status.isError { / Heartbeat operation was successful. */ }
else { / There was an error with the heartbeat operation, handle here. */ }
}
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
/
}
/
/
/
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
/
/
}
*/
}
that's my AppDelegate.swift(normal, entered just var client: PubNub!:
import UIKit
import PubNub
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, PNObjectEventListener {
var window: UIWindow?
var client: PubNub!
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
/
return true
}
func applicationWillResignActive(_ application: UIApplication) {
/
/
}
func applicationDidEnterBackground(_ application: UIApplication) {
/
/
}
func applicationWillEnterForeground(_ application: UIApplication) {
/
}
func applicationDidBecomeActive(_ application: UIApplication) {
/
}
func applicationWillTerminate(_ application: UIApplication) {
/
}
}
how can I fix it? thanks for all the answers