Expo Big Battle (39)--expo SDK API Documentpicker,contacts (get phone contact information), Branch

Source: Internet
Author: User
Tags log log

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.

Errorrecovery

Expo.ErrorRecovery.setRecoveryProps (props)
Set any error recovery properties. If your project crashes in production due to a fatal JS error, the Expo will reload your project. If you have already set these properties, they will be passed under Exp.errorrecovery to the initial properties of the item you are re-loading. Read more about the error handling of the Expo.

Parameters
Props (object)-If the item is reloaded due to a fatal JS error, the object is passed to the initial property of the reloaded project.

Documentpicker

Provides access to the system user interface to select documents from available providers on the user's device.

On iOS, for standalone applications and Expokit projects, the Documentpicker module requires icloud rights to work properly. You will need to set the Usesicloudstorage keyword to truein your App.json file, as specified in this location.

Also, for Expokit applications, you need to open the project in Xcode and follow the instructions in the Advanced Expokit topic guide using Documentpicker.

Expo.DocumentPicker.getDocumentAsync (Options)
Displays the system UI used to select the document.

Parameters
Options (object)-

Option graph:

    • Type (String)-the MIME type of the document that is available for selection. Wildcard characters such as image/* are also supported to select any image. To allow any type of file, you can use */*. the default is */*.

Return
If the user cancels the file pick, the {type: ' Cancel '} is returned.

Otherwise, return {type: ' Success ', uri,name,size} where the URI is the uri,name of the local document file is its name, and size is it in bytes.

Constacts

Provides access to the contact person of the opponent's machine system.

Expo.Contacts.getContactsAsync (Options)
Gets a list of all the entries in the system contact. This returns a set of data related to the contact entry.

Parameters

Options (object)

Option graph:

    • Field (array)-an array that describes the fields to retrieve for each contact. Each element must be one of the constants listed in the following table.
    • PageSize-the number of contacts per page that will be returned. The default is 100.
    • Pageoffset-the number of contacts to return. The default is 0.

Return
The paging object that contains the following fields.

    • Data (array)-an array of objects of form {id,name,firstname,middlename,lastname,nickname,jobtitle,company,department,imageavailable}. iOS also includes previouslastname. The other fields are listed in the following table.
    • Hasnextpage (Boolean)-if more contacts are available.
    • Haspreviouspage (Boolean)-if a contact has been skipped. True if a pageoffset greater than 0 is passed.
    • Total-number of available contacts.

Expo.Contacts.getContactByIdAsync (Options)
Gets a single contact from the system contact associated with the specified ID.

Parameter Object options
Option graph:

    • ID (String)-the ID of the contact to get.
    • Fields (array)-the array that describes the field to retrieve. Each element must be one of the constants listed in the following table.

Return
The object of the form {id,name,firstname,middlename,lastname,nickname,jobtitle,company,department,imageavailable}. iOS also includes previouslastname. The other fields are listed in the following table.

Constants and other fields (Constants and additional field)

This table describes the fields that each contact will add on demand. Example usage: Expo.Contacts.EMAILS.

Asyncfunction Showfirstcontactasync () {//Ask for permission to query contacts.  ConstPermission =awaitExpo.Permissions.askAsync (Expo.Permissions.CONTACTS); if(Permission.status!=='granted') {    //Permission was denied ...    return; }  ConstContacts =awaitExpo.Contacts.getContactsAsync ({fields: [Expo.Contacts.PHONE_NUMBERS, Expo.Contacts.EMAILS,], PageSize:Ten, Pageoffset:0,  }); if(Contacts.total >0) {Alert.alert ('Your First Contact is ...', ' Name: ${contacts.data[0].name}\n ' +' Phone numbers: ${json.stringify (contacts.data[0].phonenumbers)}\n ' +' Emails: ${json.stringify (contacts.data[0].emails)} '); }}

This feature displays the first entry in the user's contact.

Correlation type (related types)

Phonenumbers-an array containing the contact phone number data.

Fields:{ number, digits, primary (boolean), countryCode }

emails-An array of e-mail data containing the contact person.

Fields:{ email, primary (boolean) }

Addresses-an array that contains the postal address data for the contact.

Fields:{ street, city, country, region, neighborhood, postalCode, poBox, isoCountryCode }

Socialprofiles-An array of data that contains contacts ' social profiles (Facebook,twitter, etc.).

Fields:{service,localizedprofile,url,username,userid}

Instantmessageaddresses-An array of data that contains the IM address (skype,google hangouts, etc.) of the contact person.

Fields:{ service, username, localizedService }

URLs-An array containing the URL of the contact site.

Fields:{url}

Dates-contains an array of dates that are assigned to the contact.

fields:{Day, month, year}

Relationships-An array that contains the relationships that the contacts are assigned to.

Fields:{name}

Also, each entry in the above array contains the parameter ID and lable.

Birthday, nongregorianbirthday-the Gregorian and non-Gregorian calendar representations of the contact's birthday.

Fields:{ day, month, year }

thumbnail, image (thumbnail, image)-The original image of the thumbnail and contact picture.

Fields: { uri } -Use this URI as the source item for the <Image> component to display the picture. Note that getting these content on iOS is time-consuming and resource-intensive and should not be used when you get all your contacts.

Branch

The Expo includes Alpha support for the Branch attribution service.

Note: This API is only available for standalone versions created with exp build.

Import Branch
The Branch SDK is currently located under the Dangerzone namespace of the Expo because it is in a place where significant changes can occur. You can import it like this:

 from ' Expo '  = Dangerzone;
Configuration (standalone apps only)

Add Branch Key to the App.json in the Android.config.branch.apiKey and Ios.config.branch.apiKey sections. You can find your key on this page of the branch dashboard.

If you do not have a link scheme, add a link scheme to the App.json in the scenario section.

Enable Branch support for universal links (IOS only)

Branch can track common links to the domains that you associate with your app. Note: Expo will not forward these content to your JS through the normal linking API.

Enable the associated domain for your app ID on Apple's developer portal. To do this, in the App ID section, click your app ID. Select Edit, select the associated Fields check box and click Finish.

In the Link Settings section of the Branch dashboard, enable generic links and fill in your package identifiers and Apple app prefixes.

Add the associated domain in the Ios.associateddomains section to support generic links to App.json. This should be in the form of applinks:<link-domain> where the link domain can be found in the link domains section of the Branch dashboard link Settings page.

Using the Branch API

We extract the API from React-native-branch, so the documentation is the best resource. Make sure you import Branch using the instructions above (from Expo.DangerZone.Branch).

Listen for Links:

Expo.DangerZone.Branch.subscribe (Bundle) = {  if (bundle && bundle.  Params &&! bundle.error) {      //  ' Bundle.params ' contains all the info about the link.   }});

To open the Sharing dialog box:

classArticlescreen extends Component {componentdidmount () { This. Createbranchuniversalobject (); }  AsyncCreatebranchuniversalobject () {Const{Article} = This. Props;  This. _branchuniversalobject =awaitExpo.DangerZone.Branch.createBranchUniversalObject (' Article_${article.id} ', {title:article.title, ContentImageUrl:article.thumbnail, ContentDescription:article.description,//This metadata can is used to easily navigate//When the implementing deep linking with ' Branch.subscribe '.metadata: {screen:'Articlescreen',          params: Json.stringify ({articleId:article.id}),},}); } onsharelinkpress=Async() = {    ConstShareoptions ={messageheader: This. Props.article.title, MessageBody: ' Checkout myNewarticle!`,    }; await  This. _branchuniversalobject.showsharesheet (shareoptions); };}

The next one to continue the introduction, this article mainly introduces: Expo SDK API Documentpicker, Contacts (Get phone contact information), Branch ! , you are welcome to pay attention to my public number, this article is approved by everyone, my measure is the public number of fans increase number. Welcome to reprint, but must keep my blog link!

Expo Big Battle (39)--expo SDK API Documentpicker,contacts (get phone contact information), Branch

Related Article

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.