{"id":20730835,"url":"https://github.com/saasquatch/squatch-android","last_synced_at":"2025-04-23T22:02:13.232Z","repository":{"id":38981003,"uuid":"337552165","full_name":"saasquatch/squatch-android","owner":"saasquatch","description":"Official Android SDK for SaaSquatch. REST API wrapper and widgets in Android WebViews","archived":false,"fork":false,"pushed_at":"2024-11-22T18:03:34.000Z","size":341,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-03-30T03:51:12.648Z","etag":null,"topics":["android","android-webview","java","jitpack","reactive-streams","rxjava","saasquatch-java-sdk","sdk","webview"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/saasquatch.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-02-09T22:20:46.000Z","updated_at":"2024-11-22T18:03:01.000Z","dependencies_parsed_at":"2024-02-02T19:35:53.165Z","dependency_job_id":null,"html_url":"https://github.com/saasquatch/squatch-android","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saasquatch%2Fsquatch-android","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saasquatch%2Fsquatch-android/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saasquatch%2Fsquatch-android/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saasquatch%2Fsquatch-android/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/saasquatch","download_url":"https://codeload.github.com/saasquatch/squatch-android/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250522298,"owners_count":21444511,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-webview","java","jitpack","reactive-streams","rxjava","saasquatch-java-sdk","sdk","webview"],"created_at":"2024-11-17T05:12:52.430Z","updated_at":"2025-04-23T22:02:13.007Z","avatar_url":"https://github.com/saasquatch.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SquatchAndroid\n\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n[![](https://jitpack.io/v/saasquatch/squatch-android.svg)](https://jitpack.io/#saasquatch/squatch-android)\n\nHelper library for loading SaaSquatch widgets in Android WebView\n\n## Adding SquatchAndroid to your project\n\nSquatchAndroid is hosted on JitPack.\n\nAdd JitPack repository:\n\n```gradle\nallprojects {\n    repositories {\n        ...\n        maven { url 'https://jitpack.io' }\n    }\n}\n```\n\nAdd the dependency:\n\n```gradle\ndependencies {\n    implementation 'com.github.saasquatch:squatch-android:0.1.0'\n}\n```\n\nFor more information and other built tools, [please refer to the JitPack page](https://jitpack.io/#saasquatch/squatch-android).\n\nThis library relies on [SaaSquatch Java SDK](https://github.com/saasquatch/saasquatch-java-sdk), which has transitive dependencies including [RxJava 3](https://github.com/ReactiveX/RxJava), [Gson](https://github.com/google/gson), and [Apache HttpClient 5](https://hc.apache.org/httpcomponents-client-5.0.x/index.html). This library also has [RxAndroid](https://github.com/ReactiveX/RxAndroid) as a transitive dependency. **It is recommended that you explicitly import the transitive dependencies if you intend to use them**, since we may upgrade or switch to other libraries in the future. You do NOT, however, need to explicitly include [SaaSquatch Java SDK](https://github.com/saasquatch/saasquatch-java-sdk), as it is exposed in public interfaces in this library.\n\n## Using the SDK\n\nThis library is a wrapper of [SaaSquatch Java SDK](https://github.com/saasquatch/saasquatch-java-sdk) with Android specific features, specifically loading widgets into a WebView. In fact, The `SquatchAndroid` interface has a method called `getSaaSquatchClient()`, which you can use to retrieve the underlying `SaaSquatchClient`. Depending on your use case, [SaaSquatch Java SDK](https://github.com/saasquatch/saasquatch-java-sdk) may be what you need.\n\nThe entry point of the SDK is `SquatchAndroid`. To create a `SquatchAndroid` for your tenant with default options, use:\n\n```java\nSquatchAndroid.createForTenant(\"yourTenantAlias\");\n```\n\nIt is recommended that you keep a singleton `SquatchAndroid` for all your requests instead of creating a new `SquatchAndroid` for every request. `SquatchAndroid` implements `Closeable`, and it's a good idea to call `close()` to release resources when you are done with it.\n\n`SquatchAndroid` returns [Reactive Streams](https://www.reactive-streams.org/) interfaces. Assuming you are using RxJava, then a typical API call made with this SDK would look something like this:\n\n```java\nFlowable.fromPublisher(squatchAndroid.widgetUpsert(\n    WidgetUpsertInput.newBuilder()\n        .setUserInputWithUserJwt(userJwt)\n        .setWidgetType(WidgetType.ofProgramWidget(\"referral-program\", \"referrerWidget\"))\n        .setEngagementMedium(\"MOBILE\")\n        .build(),\n    null, AndroidRenderWidgetOptions.ofWebView(webView)))\n    .onErrorComplete() // or provide your own error handling\n    .subscribe();\n```\n\nIn the code above, a widget upsert is performed asynchronously with the given `userJwt`, and the resulting widget is loaded into the given `webView` with the Android main thread.\n\n## More Code Samples\n\nWidget upsert while setting a user's `customFields`\n\n```java\nfinal Map\u003cString, Object\u003e userInput = new HashMap\u003c\u003e();\nuserInput.put(\"id\", \"a\");\nuserInput.put(\"accountId\", \"a\");\nfinal Map\u003cString, Object\u003e customFields = new HashMap\u003c\u003e();\ncustomFields.put(\"birthday\", \"--12-25\");\nuserInput.put(\"customFields\", customFields);\nFlowable.fromPublisher(squatchAndroid.widgetUpsert(\n    WidgetUpsertInput.newBuilder()\n        .setUserInput(userInput)\n        .setEngagementMedium(\"MOBILE\")\n        .build(),\n    RequestOptions.newBuilder()\n        .setAuthMethod(AuthMethod.ofJwt(userJwt))\n        .build(),\n    AndroidRenderWidgetOptions.ofWebView(webView)))\n    .onErrorComplete() // or provide your own error handling\n    .subscribe();\n```\n\nRendering a widget for a user\n\n```java\nFlowable.fromPublisher(squatchAndroid.renderWidget(\n    RenderWidgetInput.newBuilder()\n        .setUserWithUserJwt(userJwt) // Can be omitted to render a widget without user information\n        .setWidgetType(WidgetType.ofProgramWidget(\"referral-program\", \"referrerWidget\"))\n        .setEngagementMedium(\"MOBILE\")\n        .build(),\n    null, AndroidRenderWidgetOptions.ofWebView(webView)))\n    .onErrorComplete() // or provide your own error handling\n    .subscribe();\n```\n\nLogging an event for a user (using the underlying `SaaSquatchClient`)\n\n```java\nfinal Map\u003cString, Object\u003e fields = new HashMap\u003c\u003e();\nfields.put(\"currency\", \"CAD\");\nFlowable.fromPublisher(squatchAndroid.getSaaSquatchClient().logUserEvent(\n    UserEventInput.newBuilder()\n        .setAccountId(\"a\")\n        .setUserId(\"a\")\n        .addEvents(UserEventDataInput.newBuilder()\n            .setKey(\"purchase\")\n            .setFields(fields)\n            .build())\n        .build(),\n    RequestOptions.newBuilder()\n        .setAuthMethod(AuthMethod.ofJwt(userJwt))\n        .build()))\n    // This is necessary so the main thread does not start the IO operation\n    .subscribeOn(Schedulers.io())\n    .onErrorComplete() // or provide your own error handling\n    .subscribe();\n```\n\n## License\n\nUnless explicitly stated otherwise all files in this repository are licensed under the Apache\nLicense 2.0.\n\nLicense boilerplate:\n\n```\nCopyright 2023 ReferralSaaSquatch.com, Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaasquatch%2Fsquatch-android","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaasquatch%2Fsquatch-android","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaasquatch%2Fsquatch-android/lists"}