From 0def9ef03a4607a115afe703c390723ba3164296 Mon Sep 17 00:00:00 2001
From: Tin Tran <tinhardware@gmail.com>
Date: Thu, 30 May 2019 17:12:02 +0700
Subject: [PATCH] add Readme

---
 .gitignore |  3 ++
 README.md  | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 101 insertions(+)
 create mode 100755 README.md

diff --git a/.gitignore b/.gitignore
index aec862d..af0396d 100755
--- a/.gitignore
+++ b/.gitignore
@@ -30,3 +30,6 @@ Pods/
 # Carthage
 Carthage/Checkouts
 Carthage/Build
+
+# Nodejs
+node_modules/
diff --git a/README.md b/README.md
new file mode 100755
index 0000000..82ed728
--- /dev/null
+++ b/README.md
@@ -0,0 +1,98 @@
+# CryptoBadge Login for the iOS app
+
+This is a simple example iOS app written in [AppAuth](hhttps://appauth.io/) and [Apollo GraphQL](https://www.apollographql.com/), and demonstrates how to 'Login with CryptoBadge' for an iOS app.
+
+## Setup & Open the Project
+
+1. In the `LoginExample` folder, run the following command to install the dependencies.
+
+```
+pod install
+```
+
+2. Open the `LoginExample.xcworkspace` workspace.
+
+```
+open LoginExample.xcworkspace
+```
+
+This workspace is configured to include AppAuth and Apollo via CocoaPods.
+
+## Configuration
+
+### Information You'll Need
+
+* Authorization Endpoint
+* Token Endpoint
+* GraphQL Endpoint
+* Client ID
+* Redirect URI
+* Scopes
+
+### Configure the Example
+
+#### In the file `AppDelegate.swift`
+
+```swift
+let kAuthorizationEndpoint  = "https://test-accounts.cryptobadge.app/oauth2/authorize";
+let kTokenEndpoint          = "https://test-accounts.cryptobadge.app/oauth2/token";
+let kGraphQLEndpoint        = "https://test-accounts.cryptobadge.app/graphql";
+let kClientID               = "f84324cdaeab89198e820c16d6721a970";
+let kRedirectURI            = "app.cryptobadge.oauth2:/oauth2redirect/sample-provider";
+let kScopes                 = ["email"]
+```
+
+#### How to update the redirect URI
+
+To allow your user to be re-directed back to LoginExample, you�셪l needs to associate a custom URL scheme with your app. The schema is everything before the colon (`:`). In web pages, for example, the scheme is usually http or https. iOS apps can specify their own custom URL schemes. For example, if the redirect URI is `app.cryptobadge.oauth2:/oauth2redirect/sample-provider`, then the scheme would be `app.cryptobadge.oauth2`. There are two way to update this schema, just choose one of them:
+
+* Update Bundle ID
+* Add CFBundleURLTypes in Info.plist
+
+##### In the file `Info.plist`
+
+Go to the `LoginExample\Supporting Files` group in Xcode and find `Info.plist`. Right click on it and choose `Open As\Source Code`.
+
+```xml
+<key>CFBundleURLTypes</key>
+<array>
+    <dict>
+        <key>CFBundleURLSchemes</key>
+        <array>
+            <string>app.cryptobadge.oauth2</string>
+        </array>
+    </dict>
+</array>
+```
+
+
+#### In the file `UserInfo.graphql`
+
+```
+query UserInfo{
+  me {
+    id
+    name
+    email
+    path
+    resourceUrl
+  }
+}
+```
+
+
+### GraphQL Usage
+
+Once you create or update graphql files, the API.swift file will be subsequently updated. You can setup Apollo GraphQL by following this guide `https://www.apollographql.com/docs/ios/installation`
+
+
+#### Update the `schema.json` file
+
+Our GraphQL service is developing so maybe this schema will out-of-date, so it may be updated manual. (TODO)
+
+`apollo-codegen` will search for GraphQL code in the Xcode project and generate the Swift types.
+
+```sh
+npm install -g apollo-codegen
+apollo-codegen download-schema http://api.cryptobadge.app/graphql --output schema
+```
-- 
GitLab