React Native module to determine whether the current user’s iCloud account can be accessed.
- 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
$ 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
$ 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-statusand addRNIcloudAccountStatus.xcodeproj - In XCode, in the project navigator, select your project. Add
libRNIcloudAccountStatus.ato your project'sBuild Phases➜Link Binary With Libraries - Run your project (
Cmd+R)
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}`);
});STATUS_COULD_NOT_DETERMINESTATUS_AVAILABLESTATUS_RESTRICTEDSTATUS_NO_ACCOUNT
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.
Copyright (c) 2020 Blockfirm AB
This project is licensed under the MIT License. See LICENSE for full license text.