From 556028114122cc195399f4b7f916c64b6a6c9fb0 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Fri, 16 Apr 2021 12:41:35 +0545 Subject: [PATCH 1/8] enabling android platform --- app/views/console/home/index.phtml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/console/home/index.phtml b/app/views/console/home/index.phtml index 1f3e95f1d9..45b7dc5b79 100644 --- a/app/views/console/home/index.phtml +++ b/app/views/console/home/index.phtml @@ -231,8 +231,8 @@ $usageStatsEnabled = $this->getParam('usageStatsEnabled',true);
  • -
  • - +
  • +
  • From b7470da9d76ae9fc09a0a8d78d9744a4419220b2 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Fri, 16 Apr 2021 13:15:35 +0545 Subject: [PATCH 2/8] adding android platform --- app/views/console/home/index.phtml | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/app/views/console/home/index.phtml b/app/views/console/home/index.phtml index 45b7dc5b79..2491a03528 100644 --- a/app/views/console/home/index.phtml +++ b/app/views/console/home/index.phtml @@ -317,6 +317,42 @@ $usageStatsEnabled = $this->getParam('usageStatsEnabled',true); + +
  • -
  • - -
  • +
  • + +
  • From 75d3c39763aacc3eec8572a5e80cb69e2d2f203d Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 1 Jun 2021 16:02:50 +0545 Subject: [PATCH 5/8] android changelog and getting started --- docs/sdks/android/CHANGELOG.md | 1 + docs/sdks/android/GETTING_STARTED.md | 55 ++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 docs/sdks/android/CHANGELOG.md create mode 100644 docs/sdks/android/GETTING_STARTED.md diff --git a/docs/sdks/android/CHANGELOG.md b/docs/sdks/android/CHANGELOG.md new file mode 100644 index 0000000000..fa4d35e687 --- /dev/null +++ b/docs/sdks/android/CHANGELOG.md @@ -0,0 +1 @@ +# Change Log \ No newline at end of file diff --git a/docs/sdks/android/GETTING_STARTED.md b/docs/sdks/android/GETTING_STARTED.md new file mode 100644 index 0000000000..6bd618505b --- /dev/null +++ b/docs/sdks/android/GETTING_STARTED.md @@ -0,0 +1,55 @@ +## Getting Started + +### Init your SDK + +

    Initialize your SDK code with your project ID, which can be found in your project settings page. + +```kotlin +import io.appwrite.AppwriteClient +import io.appwrite.services.AccountService + +val client = AppwriteClient(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + .setSelfSigned(true) // Remove in production +``` + +Before starting to send any API calls to your new Appwrite instance, make sure your Android emulators has network access to the Appwrite server hostname or IP address. + +When trying to connect to Appwrite from an emulator or a mobile device, localhost is the hostname for the device or emulator and not your local Appwrite instance. You should replace localhost with your private IP as the Appwrite endpoint's hostname. You can also use a service like [ngrok](https://ngrok.com/) to proxy the Appwrite API. + +### Make Your First Request + +

    Once your SDK object is set, access any of the Appwrite services and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the API References section. + +```kotlin +// Register User +val accountService = AccountService(client) +val user = accountService.create( + "email@example.com", + "password" +) +``` + +### Full Example + +```kotlin +import io.appwrite.AppwriteClient +import io.appwrite.services.AccountService + +val client = AppwriteClient(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + .setSelfSigned(true) // Remove in production + +val accountService = AccountService(client) +val user = accountService.create( + "email@example.com", + "password" +) +``` + +### Learn more +You can use followng resources to learn more and get help +- 📜 [Appwrite Docs](https://appwrite.io/docs) +- 💬 [Discord Community](https://appwrite.io/discord) \ No newline at end of file From c2651d56af0cc44ee500aa1ac4a65dad883b52fc Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 1 Jun 2021 16:11:51 +0545 Subject: [PATCH 6/8] improvements --- docs/sdks/android/GETTING_STARTED.md | 36 +++++++++++++++++++--------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/docs/sdks/android/GETTING_STARTED.md b/docs/sdks/android/GETTING_STARTED.md index 6bd618505b..801dcd290c 100644 --- a/docs/sdks/android/GETTING_STARTED.md +++ b/docs/sdks/android/GETTING_STARTED.md @@ -5,10 +5,10 @@

    Initialize your SDK code with your project ID, which can be found in your project settings page. ```kotlin -import io.appwrite.AppwriteClient -import io.appwrite.services.AccountService +import io.appwrite.Client +import io.appwrite.services.Account -val client = AppwriteClient(context) +val client = Client(context) .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID .setSelfSigned(true) // Remove in production @@ -24,8 +24,8 @@ When trying to connect to Appwrite from an emulator or a mobile device, localhos ```kotlin // Register User -val accountService = AccountService(client) -val user = accountService.create( +val account = Account(client) +val user = account.create( "email@example.com", "password" ) @@ -34,22 +34,36 @@ val user = accountService.create( ### Full Example ```kotlin -import io.appwrite.AppwriteClient -import io.appwrite.services.AccountService +import io.appwrite.Client +import io.appwrite.services.Account -val client = AppwriteClient(context) +val client = Client(context) .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID .setSelfSigned(true) // Remove in production -val accountService = AccountService(client) -val user = accountService.create( +val account = Account(client) +val user = account.create( "email@example.com", "password" ) ``` +### Error Handling +The Apopwrite Android SDK raises `AppwriteException` object with `message`, `code` and `response` properties. You can handle any errors by catching `AppwriteException` and present the `message` to the user or handle it yourself based on provided error information. Below is an example. + +```kotlin +try { + var response = account.create("email@example.com", "password") + Log.d("Appwrite response", response.body?.string()) +} catch(e : AppwriteException) { + Log.e("AppwriteException",e.message.toString()) +} +``` + ### Learn more You can use followng resources to learn more and get help +- 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-android) - 📜 [Appwrite Docs](https://appwrite.io/docs) -- 💬 [Discord Community](https://appwrite.io/discord) \ No newline at end of file +- 💬 [Discord Community](https://appwrite.io/discord) +- - 🚂 [Appwrite Android Playground](https://github.com/appwrite/playground-for-android) \ No newline at end of file From 7dd342b66465b2745d9d641d3c898c81ecdb1193 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 1 Jun 2021 16:13:19 +0545 Subject: [PATCH 7/8] correction --- docs/sdks/android/GETTING_STARTED.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/sdks/android/GETTING_STARTED.md b/docs/sdks/android/GETTING_STARTED.md index 801dcd290c..8d1992fa46 100644 --- a/docs/sdks/android/GETTING_STARTED.md +++ b/docs/sdks/android/GETTING_STARTED.md @@ -25,7 +25,7 @@ When trying to connect to Appwrite from an emulator or a mobile device, localhos ```kotlin // Register User val account = Account(client) -val user = account.create( +val response = account.create( "email@example.com", "password" ) @@ -43,7 +43,7 @@ val client = Client(context) .setSelfSigned(true) // Remove in production val account = Account(client) -val user = account.create( +val response = account.create( "email@example.com", "password" ) From 104f5e56855c09067083e113c709f081f007943d Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 1 Jun 2021 16:17:45 +0545 Subject: [PATCH 8/8] add platform and oauth details --- docs/sdks/android/GETTING_STARTED.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/docs/sdks/android/GETTING_STARTED.md b/docs/sdks/android/GETTING_STARTED.md index 8d1992fa46..23223d85de 100644 --- a/docs/sdks/android/GETTING_STARTED.md +++ b/docs/sdks/android/GETTING_STARTED.md @@ -1,5 +1,30 @@ ## Getting Started +### Add your Android Platform +To init your SDK and start interacting with Appwrite services, you need to add a new Flutter platform to your project. To add a new platform, go to your Appwrite console, choose the project you created in the step before, and click the 'Add Platform' button. + +From the options, choose to add a new **Flutter** platform and add your app credentials, ignoring iOS. + +Add your app name and package name, Your package name is generally the applicationId in your app-level build.gradle file. By registering your new app platform, you are allowing your app to communicate with the Appwrite API. + +### OAuth +In order to capture the Appwrite OAuth callback url, the following activity needs to be added to your [AndroidManifest.xml](https://github.com/appwrite/playground-for-flutter/blob/master/android/app/src/main/AndroidManifest.xml). Be sure to relpace the **[PROJECT_ID]** string with your actual Appwrite project ID. You can find your Appwrite project ID in you project settings screen in your Appwrite console. + +```xml + + + + + + + + + + + + +``` + ### Init your SDK

    Initialize your SDK code with your project ID, which can be found in your project settings page.