[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怎麼一下子須要,一下子又不須要?

相關文章
相關標籤/搜索