The community forums are in BETA and closed to the public.

Swift-Creating and connecting to chat channel

I'm trying to integrate 1-on-1 chat integration in my IOS app, but unfortunately, PubNub's documentation is very, very inadequate.

Here's the code:

    var configuration = PNConfiguration(publishKey: PNPublishKey, subscribeKey: PNSubscribeKey)

    configuration.uuid = "stephen"

    client = PubNub.clientWithConfiguration(configuration)


    client!.subscribeToChannels(["my_channel"], withPresence: false)      

    client!.publish("hi", toChannel: "my_channel",  withCompletion: {(status:PNPublishStatus!) in

        if !status.error

        {println("message published to channel")}


        {println("not published: \(status.error)")}


For both subscribing and publishing to chat, I'm getting a 403 status code with permission denied. I want to manage my channels on the front end, and have access to any and all channels, by any and all users that use it.

You're getting a 403 status code because you have Access Manager enabled for this subscribekey and you are not providing an authtoken with this request that has been granted access to this channel. You could either turn Access Manager off or use your secretkey to grant access to an authtoken to be used with this channel.

Login or Signup to post a comment