Skip to content

React Native module to determine whether the current user’s iCloud account can be accessed.

License

Notifications You must be signed in to change notification settings

blockfirm/react-native-icloud-account-status

Repository files navigation

React Native iCloud Account Status

React Native module to determine whether the current user’s iCloud account can be accessed.

Table of Contents

Getting started

Requirements

  • iOS 8.0+
  • The iCloud capability with CloudKit:
    1. Click on your target and then the Capabilities tab
    2. Turn on the iCloud capability
    3. Expand it and check the CloudKit option under Services

Mostly automatic installation

  1. $ npm install react-native-icloud-account-status --save
  2. React Native 0.60+: $ cd ios && pod install
    React Native <0.60: $ react-native link react-native-icloud-account-status

Manual installation

  1. $ npm install react-native-icloud-account-status --save
  2. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  3. Go to node_modulesreact-native-icloud-account-status and add RNIcloudAccountStatus.xcodeproj
  4. In XCode, in the project navigator, select your project. Add libRNIcloudAccountStatus.a to your project's Build PhasesLink Binary With Libraries
  5. Run your project (Cmd+R)

Usage

import iCloudAccountStatus from 'react-native-icloud-account-status';

iCloudAccountStatus.getStatus()
  .then((accountStatus) => {
    if (accountStatus === iCloudAccountStatus.STATUS_AVAILABLE) {
      alert('iCloud is available');
    } else {
      alert('iCloud is not available');
    }
  })
  .catch((error) => {
    alert(`Error when getting iCloud account status: ${error.message}`);
  });

API

Constants

  • STATUS_COULD_NOT_DETERMINE
  • STATUS_AVAILABLE
  • STATUS_RESTRICTED
  • STATUS_NO_ACCOUNT

Methods

getStatus()

Gets the current user's iCloud account status.

Returns a Promise that resolves to a string of one of the following:

  • 'couldNotDetermine'
  • 'available'
  • 'restricted'
  • 'noAccount'

For more information about each status, see CKAccountStatus at the Apple Developer Documentation.

License

Copyright (c) 2020 Blockfirm AB

This project is licensed under the MIT License. See LICENSE for full license text.

About

React Native module to determine whether the current user’s iCloud account can be accessed.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published