pubnub_flutter 1.0.3 copy "pubnub_flutter: ^1.0.3" to clipboard
pubnub_flutter: ^1.0.3 copied to clipboard

discontinuedreplaced by: pubnub

A new flutter plugin project.

Pubnub Flutter #

Currently available for Android only.

Pubnub plugin for Flutter apps built by Deligence Technologies. This plugin lets you integrate Pubnub in your app.

Minimum Requirements #

Android : To use this plugin you must migrate to AndroidX and set your minSdkVersion to at least 20.

Methods to use #

To Initialize #

 PubnubFlutter pubNubFlutter=PubnubFlutter();
// Getting random ID genetrated by android
String myId =await  pubNubFlutter.getUuidString();

//Initializing the plugin
pubNubFlutter=await pubNubFlutter.initialize(
           publishKey: "PUBLISH KEY",
           subscribeKey: "SUSBSCRIBE KEY",
           uuid: myId, // you can use any random Id 
           secretKey: "YOUR SECRET KEY");

Listen to change in status or msg #

  pubNubFlutter.onStatusReceived.listen((status) {
         print("check your status $status ");
    });

  pubNubFlutter.onMessageReceived.listen((msg) {
         print("\n\n RECEIVED MESSAGE IS $msg \n\n");
    });

Subscribe to channels #

// return true || false based on result
bool sub = await pubNubFlutter.subscribe(channelNames:['test@234']);

Publish msg to a channel #

// Data should be of type Map<String,String>
data={"msg":"Something something something ...."};

// return true || false based on result
 bool msg=await pubNubFlutter.sendMessage(data: data, channel: channel);

Unsubscribe to channels #


// return true || false based on result
pubNubFlutter.unsubscribe();

Note #

Currently this plugin is in development so their could be some breaking changes in next update.

Unsubscribe to a single or multiple channel is yet not supported by this plugin.