concensus / react-native-ios-concensus

React Native iOS client for Concensus
MIT License
9 stars 0 forks source link

Cannot complete Uport integration for mobile app #2

Open chronicIntrovert opened 7 years ago

chronicIntrovert commented 7 years ago

Summary

Uport integration for mobile/native apps does not have clear documentation--most documentation accounts for a front-end tech stack using Web3. Existing documentation is sparse at best, and does not include beginner-friendly language (i.e. what is a topic, and how does a topicFactory define topics or influence the request/response? Does attestation simply mean validating credentials? etc.)

Details

After carefully reading the Uport developer guide multiple times, referencing the API, and playing with Webpackbins, the farthest I could get was asking the user to login via the uriHandler.

Because there is no reference to mobile app development in the documentation, I had to complete a Google search to see what I could do for a react-native app. The only reference I found was this Github issue: https://github.com/uport-project/uport-connect/issues/39

The suggested solution was this Gist: https://gist.github.com/pelle/68287cb55253272a10d9ee9a6f7aeaf1

This helped me get Uport interactions running on the app to allow me to login, but did not provide additional info on attesting credentials or signing transactions. In addition, it makes use of the topicFactory parameter from the API, but does not explain the logic of the code nor offers to define what a topic is and what a topicFactory does. In addition, this issue introduces using native iOS linking to link between the DApp and Uport--referencing a react-native document for linking that also fails to directly explain how to setup the app schema for the url.

Furthermore, after implementing this code, the topicFactory doesn't seem to actually be called, and the mobileUrlHandler is also functionless. Removing the topicFactory and mobileUrlHandler from the uriHandler function still allows the DApp to pass the request to Uport for logging in.

Overall, Uport assumes too much proprietary knowledge of the user and fails to describe the setup process from a beginner's perspective.

Steps to Setup Uport App

  1. Download Uport ID app for iOS
  2. Create identity on Uport ID app
  3. Register DApp in Uport portal (http://developer.uport.me/myapps.html)

Steps to Reproduce Uport Integration Attempt

  1. npm install --save uport-connect derequire
  2. Run: node_modules/.bin/derequire node_modules/uport-connect/dist/uport-connect.js > src/vendor/uport-connect.js
  3. Set crypto and stream to false under react-native in package.json
  4. Setup uport in app:
    
    const UportConnect = require('../src/vendor/uport-connect.js');

const Connect = UportConnect.ConnectCore; const SimpleSigner = UportConnect.SimpleSigner;

const rpcUrl = 'https://rinkeby.infura.io/TN4nYidPt24zcMvOVYIE';

import URL from 'url-parse'; import qs from 'qs';

const uriHandler = (url) => { console.log(url); Linking.openURL(url); };

export const uport = new Connect('Concensus', { clientId: '2oek8Yv9tnhCqWXb3sS2v7orpWsje1MZPAm', network: 'rinkeby', signer: SimpleSigner('0a1f0c6a1ad43ccac720948a3f29556cc453df72ed969ee93eca85b80f7908aa'), uriHandler: uriHandler, rpcUrl });

function authenticateWithUport() { uport.requestCredentials({ requested: ['name', 'avatar', 'phone', 'country'], notifications: true }).then(profile => { /

Additional Comments

Another issue faced was setting up the DApp in the Uport portal. It appeared that after several attempts, the app would not save and form a transaction with the Uport ID app. This eventually resolved itself, although problems with registering continued to arise intermittently.

amazingandyyy commented 7 years ago

follow up

Vijay-clustrex commented 6 years ago

Hi @imthinhvu

I followed the steps given above by you. After that no errors but getting the value of "uport" is undefined.Can you suggest me anything related this?