npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@photon-sdk/react-native-icloudstore

v1.0.0

Published

Drop-in replacement for AsyncStorage that uses iCloud ubiquitous key-value store.

Downloads

47

Readme

react-native-icloudstore 📱☁️📱

npm version

A drop in replacement for React Native's AsyncStorage API that wraps the iCloud Ubiquitous Key-Value Store.

Usage

In your target's "capabilities" tab in Xcode, make sure that iCloud is switched on as well as make sure that the "Key-value storage" option is checked.

react-native-icloudstore mimicks the same promise-based API as AsyncStorage. In addition to all of the AsyncStorage methods, there is one additional feature: a native event (iCloudStoreDidChangeRemotely) that lets you know when your store changed due to a remote change (i.e. from another device on the same iCloud account). See the example below for a very basic way to make use of that in your React Native application. For apps that use redux, you may want to call an appropriate action creator upon receiving the event.

import { NativeEventEmitter } from 'react-native';
import iCloudStorage from '@photon-sdk/react-native-icloudstore';

...

  componentWillMount() {
    this.eventEmitter = new NativeEventEmitter(iCloudStorage);
    this.eventEmitter.addListener('iCloudStoreDidChangeRemotely', this.loadData);
  }

  componentWillUnmount() {
    this.eventEmitter.remove();
  }

  loadData = (userInfo) => {
    const changedKeys = userInfo.changedKeys;
    if (changedKeys != null && changedKeys.includes('MY_STORAGE_KEY')) {
      iCloudStorage.getItem('MY_STORAGE_KEY').then(result => this.setState({ storage: result }));
    }
  }
  
...
  

Install

npm install --save @photon-sdk/react-native-icloudstore

Automatically link

With React Native 0.27+

react-native link @photon-sdk/react-native-icloudstore

With older versions of React Native

You need rnpm (npm install -g rnpm)

rnpm link @photon-sdk/react-native-icloudstore

Manually link

iOS (via Cocoa Pods)

Add the following line to your build targets in your Podfile

pod 'RNICloudStore', :path => '../node_modules/@photon-sdk/react-native-icloudstore'

Then run pod install

iOS (without Cocoa Pods)

In XCode, in the project navigator:

  • Right click Libraries
  • Add Files to [your project's name]
  • Go to node_modules/@photon-sdk/react-native-icloudstore
  • Add the .xcodeproj file

In XCode, in the project navigator, select your project.

  • Add the libicloudstorage.a from the deviceinfo project to your project's Build Phases ➜ Link Binary With Libraries
  • Click .xcodeproj file you added before in the project navigator and go the Build Settings tab. Make sure All is toggled on (instead of Basic).
  • Look for Header Search Paths and make sure it contains both $(SRCROOT)/../react-native/React and $(SRCROOT)/../../React
  • Mark both as recursive (should be OK by default).

Run your project (Cmd+R)

Android

Android isn't supported - importing will simply return AsyncStorage so your app should continue to work.

Feedback

Questions? Comments? Feel free to email me.

If you have an issue, please create an issue under the "Issues" tab above. Or, feel free to issue a pull request. 🤓