0

I'm using PubNub 4.2.5 on Swift IOS9.2 and received this conflect error message, any ideas how to resolve..thanks!

/Users/XXXX/xcode/XXXX/PubNub5/PubNub5/AppDelegate.swift:91:10: Objective-C method 'client:didReceiveStatus:' provided by method 'client(_:didReceiveStatus:)' conflicts with optional requirement method 'client(_:didReceiveStatus:)' in protocol 'PNObjectEventListener'

Function

//Handle subscription status change.
    func client(client: PubNub!, didReceiveStatus status: PNSubscribeStatus) {


    }
ryeo
  • 135
  • 1
  • 1
  • 6

1 Answers1

0

PubNub Subscribe iOS SDK Listener

The appropriate class should be PNSubscribeStatus.

The full subscribe code would like like the code below. See the full docs for PubNub iOS Swift SDK v4.x subscribe API.

self.client?.subscribeToChannels(["my_channel1","my_channel2"], withPresence: false)
 
 
// Handle new message from one of channels on which client has been subscribed.
func client(client: PubNub!, didReceiveMessage message: PNMessageResult!) {
 
    // Handle new message stored in message.data.message
    if message.data.actualChannel != nil {
 
        // Message has been received on channel group stored in
        // message.data.subscribedChannel
    }
    else {
 
        // Message has been received on channel stored in
        // message.data.subscribedChannel
    }
 
    print("Received message: \(message.data.message) on channel " +
                "\((message.data.actualChannel ?? message.data.subscribedChannel)!) at " +
                "\(message.data.timetoken)")
}
 
// Handle subscription status change.
func client(client: PubNub!, didReceiveStatus status: PNSubscribeStatus!) {
 
    if status.category == .PNUnexpectedDisconnectCategory {
 
        // This event happens when radio / connectivity is lost
    }
    else if status.category == .PNConnectedCategory {
 
        // Connect event. You can do stuff like publish, and know you'll get it.
        // Or just use the connected event to confirm you are subscribed for
        // UI / internal notifications, etc
    }
    else if status.category == .PNReconnectedCategory {
 
        // Happens as part of our regular operation. This event happens when
        // radio / connectivity is lost, then regained.
    }
    else if status.category == .PNDecryptionErrorCategory {
 
        // Handle messsage decryption error. Probably client configured to
        // encrypt messages and on live data feed it received plain text.
    }
}
Community
  • 1
  • 1
Craig Conover
  • 4,710
  • 34
  • 59