{"id":18996313,"url":"https://github.com/csfrequency/firebase-device-store-android-sdk","last_synced_at":"2025-08-11T02:05:26.638Z","repository":{"id":66234371,"uuid":"185956863","full_name":"CSFrequency/firebase-device-store-android-sdk","owner":"CSFrequency","description":"Automatically store Device and FCM Token information for Firebase Auth Users in Cloud Firestore","archived":false,"fork":false,"pushed_at":"2019-06-14T08:29:09.000Z","size":88,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-08T22:03:07.564Z","etag":null,"topics":["android-sdk","fcm","firebase","firebase-auth","firebase-authentication","firebase-cloud-firestore","firebase-cloud-messaging","firebase-firestore","firebase-messaging","firestore","java"],"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/CSFrequency.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2019-05-10T09:09:45.000Z","updated_at":"2021-02-04T13:36:10.000Z","dependencies_parsed_at":"2023-02-24T01:01:12.198Z","dependency_job_id":null,"html_url":"https://github.com/CSFrequency/firebase-device-store-android-sdk","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/CSFrequency/firebase-device-store-android-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CSFrequency%2Ffirebase-device-store-android-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CSFrequency%2Ffirebase-device-store-android-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CSFrequency%2Ffirebase-device-store-android-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CSFrequency%2Ffirebase-device-store-android-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CSFrequency","download_url":"https://codeload.github.com/CSFrequency/firebase-device-store-android-sdk/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CSFrequency%2Ffirebase-device-store-android-sdk/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269819032,"owners_count":24480087,"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","status":"online","status_checked_at":"2025-08-11T02:00:10.019Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-sdk","fcm","firebase","firebase-auth","firebase-authentication","firebase-cloud-firestore","firebase-cloud-messaging","firebase-firestore","firebase-messaging","firestore","java"],"created_at":"2024-11-08T17:34:39.502Z","updated_at":"2025-08-11T02:05:26.612Z","avatar_url":"https://github.com/CSFrequency.png","language":"Java","readme":"# Firebase Device Store (Android SDK)\n\nAutomatically store Device and FCM Token information for Firebase Auth Users in Cloud Firestore.\n\n[![Download](https://api.bintray.com/packages/csfrequency/maven/firebase-device-store-android-sdk/images/download.svg) ](https://bintray.com/csfrequency/maven/firebase-device-store-android-sdk/_latestVersion)\n\n\u003e This library is a proof of concept, and very much a work in progress.\n\n## Installation\n\nAdd the following dependency to your `app/build.gradle`:\n\n```\nimplementation \"com.csfrequency.firebase.devicestore:firebase-device-store:0.1.3\"\n```\n\n## Example usage\n\n  ```\n  import com.csfrequency.firebase.devicestore.FirebaseDeviceStore;\n\n  FirebaseDeviceStore deviceStore = new FirebaseDeviceStore(this.getApplicationContext(), FirebaseApp.getInstance(), \"user-devices\");\n  deviceStore.subscribe();\n  ```\n\n## Documentation\n\nFirebase Device Store automatically stores device and FCM information for Firebase Auth users in Cloud Firestore.\n\n### Data Model\n\nA Document is created in the Cloud Firestore collection for each logged in user:\n\n```\n/user-devices\n  - userId1: {},\n  - userId2: {},\n```\n\nThe structure of this Document is as follows:\n\n```\n{\n  devices: {\n    deviceId1: Device,\n    deviceId2: Device,\n    ...\n  },\n  userId: string,\n}\n```\n\nA `Device` object contains the following:\n\n```\n{\n  deviceId: string, // A UUID for the device\n  fcmToken: string, // The FCM token\n  name: string,     // The name of the device (e.g. 'Bob's Google Pixel')\n  os: string,       // The OS of the device\n  type: 'Android'\n}\n```\n\n### API\n\n#### `FirebaseDeviceStore(context: Context, app: FirebaseApp, collectionPath: string)`\n\nCreate a new DeviceStore.\n\nParameters:\n\n- `context`: `Context` the application context\n- `app`: `FirebaseApp` (Optional) the Firebase App to use. Defaults to the default Firebase App.\n- `collectionPath`: (Optional) `string` the Cloud Firestore collection where devices should be stored. Defaults to `user-devices`.\n\nReturns a `FirebaseDeviceStore`.\n\n#### `FirebaseDeviceStore.signOut(): Task\u003cVoid\u003e`\n\nIndicate to the DeviceStore that the user is about to sign out and that the current device token should be removed.\n\nThis can't be done automatically with `onAuthStateChanged` as the user is already signed out at this point. This means the Cloud Firestore security rules will prevent the database deletion as they no longer have the correct user permissions to remove the token.\n\nYou should wait for the task to complete before signing the user out of your application.  This will ensure that the device is correctly removed.\n\n#### `FirebaseDeviceStore.subscribe(): void`\n\nSubscribe a device store to the Firebase App. This will:\n\n1. Subscribe to Firebase Auth and listen to changes in authentication state\n2. Subscribe to Firebase Cloud Messaging and listen to changes in the FCM token\n3. Automatically store device and FCM token information in the Cloud Firestore collection you specify\n\n#### `FirebaseDeviceStore.unsubscribe(): void`\n\nUnsubscribe the device store from the Firebase App.\n\n### Security rules\n\nYou will need to add the following security rules for your Cloud Firestore collection:\n\n```\nservice cloud.firestore {\n  match /databases/{database}/documents {\n    // Add this rule, replacing `user-devices` with the collection path you would like to use:\n    match /user-devices/{userId} {\n      allow create, read, update, delete: if request.auth.uid == userId;\n    }\n  }\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsfrequency%2Ffirebase-device-store-android-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcsfrequency%2Ffirebase-device-store-android-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsfrequency%2Ffirebase-device-store-android-sdk/lists"}