[RN] 03 - Resource Collection & AWS Auth

那些资源


1、三个例子html

iReading前端

Bilibili-React-Nativenode

ZhiHuDaily-React-Nativereact

 

2、IM 例子

1. React Native Socket.io Examplelinux

2. A simple messaging app with React Native and Socket.ioandroid

3. 极光Aurora IMUIios

4. 一个基于 react-native + mobx + socket.io + node 的仿微信 JS-Wechatgit

 

3、业内良心

Goto: React Native Community【相对权威】github

Goto: react-native-open-project 【工程】web

Goto: Useful-Open-Source-React-Native 【控件】

Goto: react-native-starter-kit      【网页+RN】

Goto: 30-days-of-react-native    【30个demo】

Goto: aws-samples/aws-mobile-react-native-starter 【serverless】

Goto: https://github.com/wangdicoder【可用方案】

 

4、国外良心

Ref: https://github.com/jondot/awesome-react-native 【UI,App资源极为丰富】

 

5、运行例子

运行ZhiHuDaily报错,以及处理办法。

可能出现的错误,惋惜没完全解决:

(1) 先用Android Studio打开工程,不然直接npm install会报错。

 

(2) Gradle 'app' project refresh failed.

Error:Unsupported method: BaseConfig.getApplicationIdSuffix().
The version of Gradle you connect to does not support that method.
To resolve the problem you can change/upgrade the target version of Gradle you connect to.
Alternatively, you can ignore this exception and read other information from the model.

Consult IDE log for more details (Help | Show Log)

 

(3) 在ZhiHuDaily-React-Native/android/gradle/wrapper/gradle-wrapper.properties中升级到4.1。

distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

 

From: Unsupported method: BaseConfig.getApplicationIdSuffix() 

  • Open build.gradle and change the gradle version to the recommended version:
    classpath 'com.android.tools.build:gradle:1.3.0' to
    classpath 'com.android.tools.build:gradle:2.3.2'
  • Hit 'Try Again'
  • In the messages box it'll say 'Fix Gradle Wrapper and re-import project' Click that, since the minimum gradle version is 3.3
  • A new error will popup and say The SDK Build Tools revision (23.0.1) is too low for project ':app'. Minimum required is 25.0.0 - Hit Update Build Tools version and sync project
  • A window may popup that says Android Gradle Plugin Update recommended, just update from there.

Now the project should be runnable now on any of your android virtual devices.

 

(4) 继续报错

gradle project sync failed. basic functionality will not work properly android studio

Goto: Android Studio 3.0.1 Error: Gradle project sync failed. Basic functionality (e.g. editing, debugging) will not work properly

 

 

 

 

让咱们从AWS登陆开始


 

登陆: aws-samples/aws-mobile-react-native-starter 【serverless】

--> 侧边栏 --> 按钮列表、路由

台湾哥们的好文,收之:使用 REACT NATIVE 與 AMAZON COGNITO 實做 GOOGLE & FACEBOOK 登入的功能

  

1、React or React Native

Adding authentication to your React or React Native app is as easy as wrapping your app's main component with our withAuthenticator higher order component.

AWS Amplify will provide you customizable UI for common use cases such as user registration and login.

import { withAuthenticator } from 'aws-amplify-react-native';

export default withAuthenticator(App);

 

 

2、React Native apps with [AWS Amplify]

Ref: 官方开发指导

 

  • 一些概念

CLI support: AWS 命令行界面

AWS Mobile Hub: 建立AWS资源、相关用户、安全机制等

awsmobile-cli: It provides utilities for managing your backend, without visiting AWS Mobile Hub console.

 

  • 用户登陆

As an example, in you React Native app, you can use a Higher-Order Components to provide a sign-in/sign-out experience for your app simply by wrapping your app’s main component:

export default withAuthenticator(App);

一行代码搞定登陆前端。 

 

  • 用户检测

Monitoring your users’ interaction with your app.

AWS Amplify provides analytics, push notifications and targeted messaging capabilities out-of-the-box.

Analytics.record('albumVisit', { genre: 'jazz', artist: 'Miles Davis' });

 

  • 动手实践

详见:Create an app

参见:[RN] 01 - Init: Try a little bit of React Native

 

(1) 打开Access keys,而后 “Create New Access Key”。 

 

(2) 手动配置后端

 

官方代码中应该有实例: aws-amplify/packages/aws-amplify-react-native/

 

 

 

 

RN for AWS AUTH


官方的不够良心,这个才是真爱:Expo - React Native Authentication with Expo, AWS Amplify, & Cognito

对应的代码:dabit3/expo-user-authentication

 

1、安装

代码需安装:
npm install aws-amplify npm install react-navigation

【五星级教程笔记】

Ref: AWS Mobile Hub 【React Native Training 五星级资源】

 

本篇内容为如下的四篇学习笔记:

  • 1. AWSMobile CLI - Getting Started
  • 2. Adding Analytics to a React Native Application
  • 3. Expo - React Native Authentication with Expo, AWS Amplify, & Cognito【以前已阅】
  • 4. Adding Analytics to an Expo Project
  • 5. React Native iOS Push Notifications with AWS & Amazon Pinpoint
 
 

1、 AWSMobile CLI 自动配置

AWSMobile CLI 与3相似,就是自动配置后端:
【这里没有说起密钥
 

 

2、IAM

(1) 添加用户到组。

 

(2) 添加一个组,这个组须要给予适当的权限,好比admin。

 

(3) 而后得到两个key,运行awsmobile configure时有用到。

【这里有说起密钥

 

 

3、amazon-cognito-identify-js

仍是自动化配置后端那一套。

貌似是与Amplify取得联系。

react-native link amazon-cognito-identify-js

 

加载app到模拟器。

npm start    # kick off the package react-native run-ios

 

 

4、两个疑问?

secretAccessKey怎么一下子须要,一下子又不须要?

相关文章
相关标签/搜索