1.0.5 • Published 6 years ago

ns-pubnub v1.0.5

Weekly downloads
1
License
Apache-2.0
Repository
-
Last release
6 years ago

NativeScript PubNub apple

THIS IS NOT READY FOR PRODUCTION, JUST FOR DEVELOPING/TESTING

This plugin is allows you to use the PubNub Objective-C SDK in your NativeScript app.

Installation

tns plugin add ns-pubnub

Usage

// import
import { Pubnub, PubnubConfig, PubnubOptions } from 'ns-pubnub';

// configure
const pubnubConfig: PubnubConfig = {
  publishKey: 'demo',
  subscribeKey: 'demo'
}

const pubnubOptions: PubnubOptions = {
  cipherKey: 'a12345',
  suppressLeaveEvents: false
}

let pubnub = new Pubnub(pubnubConfig, pubnubOptions);

// subscribe
pubnub.subscribe(channels: string[], withPresence: boolean)

pubnub.subscribeToChannelGroups(groups: string[], shouldObservePresence: boolean)

// publish message
pubnub.publish('my_channel', "message", (status) => {
  conosle.log(status.information)
})

// listen to receive events
pubnub.on('receiveMessage', (data) => {
  console.log(data)
})
pubnub.on('receivePresenceEvent', (data) => {
  console.log(data)
})
pubnub.on('receiveStatus', (data) => {
  console.log(data)
})

// unsubscribe
pubnub.unsubscribe(channels: string[], withPresence: boolean)

pubnub.unsubscribeFromChannelGroups(groups: string[], withPresence: boolean)

pubnub.unsubscribeFromAll()

Options (PubnubOptions)

PropertyTypeDefaultDescription
cipherKeystring_Key which is used to encrypt messages pushed to PubNub service and decrypt messages received from live feeds on which client subscribed at this moment.
stripMobilePayloadboolean_Stores whether client should strip out received messages (real-time and history) from data which has been appended by client (like mobile payload for push notifications).
subscribeMaximumIdleTimenumber310Maximum number of seconds which client should wait for events from live feed.
nonSubscribeRequestTimeoutnumber10Number of seconds which is used by client during non-subscription operations to check whether response potentially failed with timeout or not.
presenceHeartbeatValuenumber_Number of seconds which is used by server to track whether client still subscribed on remote data objects live feed or not.
presenceHeartbeatIntervalnumber_Number of seconds which is used by client to issue heartbeat requests to PubNub service.
keepTimeTokenOnListChangebooleantrueWhether client should keep previous time token when subscribe on new set of remote data objects live feeds.
catchUpOnSubscriptionRestorebooleantrueWhether client should try to catch up for events which occurred on previously subscribed remote data objects feed while client was off-line.
applicationExtensionSharedGroupIdentifierstring_Reference on group identifier which is used to share request cache between application extension and it's containing application. This property should be set to valid registered group only if PubNub client is used inside of application's extension (iOS 8.0+, macOS 10.10+).
requestMessageCountThresholdnumberNumber of maximum expected messages from PubNub service in single response.
maximumMessagesCacheSizenumber100Messages de-duplication cache size
completeRequestsBeforeSuspensionbooleantrueWhether client should try complete all API call which is done before application will be completely suspended.
suppressLeaveEventsboolean_Whether client shouldn't send presence leave events during unsubscription process.

License

Apache License Version 2.0, January 2004