Expo Big Battle (29)--expo SDK API Registerrootcomponent (registration with components), screenorientation (screen switching), Securestore,

Source: Internet
Author: User
Tags log log alphanumeric characters

Brief: This series of articles will be a comprehensive introduction to the Expo, I contact the Expo since June 2017, the study of the Expo intermittent, all the way to nearly 10 months, nonsense not to say, next you see the content, speak all to the official website

I guess go all machine turn + personal modification supplement +demo test form, to the expo to do a big blood! Welcome to join the Expo Interest Learning Exchange Group: 597732981

"Before I wrote some columns about Expo and RN entry configuration for East I west, you can click here to view: from zero learning RN development"

Related articles:

Expo Big Battle (a)--what is the expo, how to install Expo Clinet and xde,xde how to use

Expo Big Battle (ii)--expo life cycle, Expo Community exchanges, Expo learning necessary resources, the development of the use of the expo concerns some issues

Expo Big Battle (iii)--to the development of react native project developers have targeted the introduction of the limitations of Expo,expo, the development of project selection points of attention, etc.

Expo Big Battle (Iv.)--Rapid use of Expo to build a key term in a App,expo

Expo Big Battle (v) configuration information for App.json files in--expo

Expo Big Battle (vi)--EXPO Development mode, Expo in the EXP Command line tool, Expo How to view the debug mode in the log Log,expo

Expo Big Battle (vii)--expo How to use Genymotion simulator

Expo Big Battle (eight)--expo in the Publish and Expo link, to link this piece of things not detailed see, we can come to communicate with me

More >>

Written in chapter 23 after the words, before the translation, no matter how, good and bad, after all, is the end of the expo, but also the basic theory of the things in-depth understanding again, the following Expo big Battle series will mainly introduce the Expo SDK API.

Securestore

Provides methods for locally encrypting and securely storing key-value pairs on the device. Each Expo project has a separate storage system and cannot access the storage of other expo items.

IOS: Use the Keychain service to store values as Ksecclassgenericpassword. iOS has additional options to set the value of the Ksecattraccessible property, which controls when the value can be obtained.

Android: Values are stored in sharedpreferences and encrypted using Android's KeyStore system.

Expo.SecureStore.setItemAsync (key,value,options)
Stores key-value pairs.

Parameters

Key (string)-the key associated with the stored value. The key may contain alphanumeric characters. ,-and _ (Keys may contain alphanumeric characters . , and - _ .).

Value (string)-the value to store.

Options (object) (optional) (Options ( Object) (optional))-option graph:

Keychainservice (string)-

    • IOS: The service of the project, equivalent to Ksecattrservice
    • Android: Equivalent to a public/private key pair Alias

Note If you set the item by using the Keychainservice option, you need to get the value later.

Keychainaccessible (enum) -

iOS only: Use the iOS ksecattraccessible property to specify when storage entries are accessible. See Apple's documentation on keychain item accessibility. The available options are:

    • Expo.SecureStore.WHEN_UNLOCKED: Data in a keychain item can only be accessed when the device is unlocked by the user.
    • Expo.SecureStore.AFTER_FIRST_UNLOCK: The data in the keychain item cannot be accessed after a reboot until the user unlocks the device once. This can be useful if you need to access the item when your phone is locked.
    • Expo.SecureStore.ALWAYS: Data in keychain items can always be accessed regardless of whether the device is locked. This is the least secure option.
    • Expo.SecureStore.WHEN_UNLOCKED_THIS_DEVICE_ONLY: Similar to when_unlocked, but does not migrate entries to new devices when restoring from a backup.
    • Expo.SecureStore.WHEN_PASSCODE_SET_THIS_DEVICE_ONLY: Similar to when_unlocked_this_device_only, a user must set a password to store an entry. If the user deletes their password, the entry will be deleted.
    • Expo.SecureStore.AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY: Similar to After_first_unlock, but does not migrate entries to new devices when restoring from a backup.
    • Expo.SecureStore.ALWAYS_THIS_DEVICE_ONLY: Similar to always, but does not migrate entries to new devices when restoring from a backup.
Return

If the value cannot be stored on the device, then the commitment is rejected (A promise that would reject if value cannot be stored the device.)

Expo.SecureStore.getItemAsync (key,options)
Gets the stored value associated with the provided key.

Parameters

Key (string)-the key used to store the associated value.

Options (object) (optional)-option graph:

Keychainservice (String)-IOS: Project service, equivalent to Ksecattrservice. Android: Equivalent to a public/private key pair alias.

Note If you set the item by using the Keychainservice option, you need to get the value later.

Return

A commitment that resolves to a previously stored value, or null if there is no entry for the given key. If an error occurs while retrieving a value, the commitment is rejected.

Expo.SecureStore.deleteItemAsync (keys, options)
Deletes the value associated with the supplied key.

Parameters

Key (string)-the key used to store the associated value.

Options (object) (optional)-option graph:

Keychainservice (String)-IOS: Project service, equivalent to Ksecattrservice. Android: Equivalent to a public/private key pair alias. If the project is set using Keychainservice, you need to get the value later.

Return

If the value cannot be deleted, the promise will be rejected.

It's also a good thing to be safe with this localized storage, providing a way to encrypt and securely store key-value pairs locally on your device. Each Expo project has a separate storage system and cannot access the storage of other expo items.

Screenorientation

Allows you to change the supported screen orientation at run time. This will take precedence over the arrow keys in the App.json.

Expo.ScreenOrientation.allow(orientation)

Allows screen orientation. You can use multiple directions to call this function multiple times to allow multiple orientations.

Parameters

Orientation (string)-the allowable direction. See direction enumeration for possible values.

Cases

function Changescreenorientation () {  Expo.ScreenOrientation.allow ( Expo.ScreenOrientation.Orientation.LANDSCAPE);}
Expo.ScreenOrientation.Orientation

An object that contains the value that can be passed to the Allow function. (Several enumeration types, which delegates can pass to Expo.ScreenOrientation.allow(orientation)的参数 )

    • ALL-All 4 possible directions
    • All_but_upside_down-In addition to the reverse portrait, it may be in all 4 directions on some Android devices.
    • PORTRAIT-Portrait orientation, may also be a reverse portrait on some Android devices.
    • PORTRAIT_UP-Ascending portrait only. (Upside portrait only.)
    • Portrait_down-Inverted portrait only.
    • LANDSCAPE-Any scenic location.
    • Landscape_left-left View only.
    • Landscape_right-Right View only.

The following is the original text:

  • ALL-all 4 Possible orientations

  • ALL_BUT_UPSIDE_DOWN-all but reverse portrait, could is all 4 orientations on certain Android devices.

  • PORTRAIT-portrait orientation, could also be reverse Portrait on certain Android devices.

  • PORTRAIT_UP-upside portrait only.

  • PORTRAIT_DOWN-upside down portrait only.

  • LANDSCAPE-any landscape orientation.

  • LANDSCAPE_LEFT-left landscape only.

  • LANDSCAPE_RIGHT-right landscape only.

When the detection direction changes (detecting when the orientation changes)

The best way to do this is to listen for changes to the dimensions. (The best-of-the-listen for changes to Dimensions.)

Registerrootcomponent Expo.registerRootComponent(component)

Set the main components that Expo uses for your application.

Note: Before SDK 18, it is necessary to use registerrootcomponent directly, but for projects created from SDK 18 or later, this will be handled automatically in the Expo SDK.

Parameters

Component (Reactcomponent)-Renders the react component class for the remainder of the application.

Return

no return value. (No return value.)

Note: Expo.registerrootcomponent is roughly equivalent to react Native's appregistry.registercomponent and provides some additional hooks to provide the specific functionality of the Expo (which is another high-level package for appregistry.registercomponent).

Problems

I created my project before SDK 18, and I want to remove expo.registerrootcomponent, what should I do?

    • Before you continue, make sure that your project is running on SDK 18 or later.
    • Open Main.js (or if you change it, whether your "main" is in Package.json). (Open up main.js (or if you changed it, whatever your are in "main" package.json ).)
    • Set "main" to "Node_modules/expo/appentry.js".
    • Remove the expo.registerrootcomponent call from Main.js and place the export default value before the class declaration of the root component. (Delete the call from and Expo.registerRootComponent main.js put export default before your root component ' s class declaration.)
    • Rename the main.js to App.js.
What if I want to name my main application file as something other than app.js?

You can set "main" in Package.json to any file in the project. If you do, then you need to use registerrootcomponent; If you use a custom entry file, exporting the default value will not make the component the root of the Expo application.

For example, suppose you want to use "src/main.js" as an entry file for your application-for example, you might not like to include JavaScript files in your project's root directory. First, set it in Package.json:

{  "main""src/main.js"}

Then in "Src/main.js", make sure you call Registerrootcomponent () and pass the component you want to render to the application's root directory.

 from ' Expo '  from 'react' to ' react-native  '; class App extends React.component {  render () {    return <view/>;  }} Expo.registerrootcomponent (APP);

This part is very useful, everybody slowly realize, use when, use!

Next continue to introduce, this article mainly introduces: Expo SDK API registerRootComponent(注册跟组件), screenorientation (screen switching), Securestore, Welcome to my public number, Whether this article is approved by everyone, my measure is the number of public number of fans increase. Welcome to reprint, but must keep my blog link!

Expo Big Battle (29)--expo SDK API Registerrootcomponent (registration with components), screenorientation (screen switching), Securestore,

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.