Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
android
ios
.babelrc
.buckconfig
.flowconfig
.gitattributes
.gitignore
.watchmanconfig
App.js
README.md
app.json
index.js
package-lock.json
package.json
yarn.lock

README.md

React Native IBM Push Sample

This is a React-Native Sample Application for demonstrating usage of IBM Push Notifications.

Checkout this link to know more: JSONStore - IBM Mobile Foundation Developer Center

Setting up the Sample

  1. Get into the project directory:

cd JSONStoreReactNative

  1. Install the project dependencies:

npm install

Running the Sample

For android:

react-native run-android For iOS: react-native run-ios

Understanding the Sample

Creating a collection:

To create a collection, we use the JSONStoreCollection constructor. We must specify the name of the Collection.

var collection = new JSONStoreCollection('people');

Opening a collection:

Just creating a collection won’t let you interact with it. One must open that JSONStoreCollection to start manipulating it.

For this purpose we use openCollections API of WLJSONStore class. It accepts an array of name of collections to be opened.

Optionally, you can also pass Initialization Options to openCollections API, to open a collection with configuration like Synchronization.

  • Without InitOptions:
var collection = new JSONStoreCollection('people');
WLJSONStore.openCollections(['people'])
.then(res => {
  // success
}).catch(err => {
	// failure
});
  • With InitOptions:
var collection = new JSONStoreCollection('people');
var options = new JSONStoreInitOptions();
options.setSyncOptions(
	JSONStoreSyncPolicy.SYNC_UPSTREAM, 	"JSONStoreCloudantSync"
);
WLJSONStore.openCollections(['people'], options)
.then(res => {
  // success
}).catch(err => {
	// failure
});
Adding a JSONStore Document:

You can use addData API of JSONStoreCollection class to add data to the collection. It accepts both, a single JSON and array of JSON as a parameter.

var data = {"name": "John Doe", "age": 25};
collection.addData(data)
.then(res => {
	// success          
}).catch(err => {
	// failure
});
Finding Documents:

JSONStoreCollection provides you with a rich set of APIs to find your documents. To find all the documents in a collection use findAllDocuments API. Check this out for more info about Querying your JSONStoreCollection

collection.findAllDocuments().then(data => {
 	// success
}).catch(err => {
 	// failure
});
Clearing a Collection:

Clearing a collection means to remove all the contained documents in a JSONStore collection. Remember, the Collection still exist, just that it will be empty now.

collection.clearCollection().then(res => {
 	// success
}).catch(err => {
 	// failure
});
You can’t perform that action at this time.