1.0.2 • Published 5 years ago
react-native-icloud-account-status v1.0.2
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:
- Click on your target and then the Capabilities tab
- Turn on the iCloud capability
- Expand it and check the CloudKit option under Services
Mostly automatic installation
$ npm install react-native-icloud-account-status --save
- React Native 0.60+:
$ cd ios && pod install
React Native <0.60:$ react-native link react-native-icloud-account-status
Manual installation
$ npm install react-native-icloud-account-status --save
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-icloud-account-status
and addRNIcloudAccountStatus.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNIcloudAccountStatus.a
to your project'sBuild Phases
➜Link Binary With Libraries
- 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) 2019 Blockfirm AB
This project is licensed under the MIT License. See LICENSE for full license text.