{"id":14973108,"url":"https://github.com/csfrequency/firebase-device-store-ios-sdk","last_synced_at":"2026-02-06T12:38:32.731Z","repository":{"id":56911278,"uuid":"186649327","full_name":"CSFrequency/firebase-device-store-ios-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:25:30.000Z","size":32,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-06T21:59:53.405Z","etag":null,"topics":["firebase","firebase-auth","firebase-authentication","firebase-cloud-firestore","firebase-cloud-messaging","firebase-firestore","firebase-messaging","ios-sdk","swift"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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}},"created_at":"2019-05-14T15:22:35.000Z","updated_at":"2023-03-09T15:19:10.000Z","dependencies_parsed_at":"2022-08-21T03:20:17.282Z","dependency_job_id":null,"html_url":"https://github.com/CSFrequency/firebase-device-store-ios-sdk","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/CSFrequency/firebase-device-store-ios-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CSFrequency%2Ffirebase-device-store-ios-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CSFrequency%2Ffirebase-device-store-ios-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CSFrequency%2Ffirebase-device-store-ios-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CSFrequency%2Ffirebase-device-store-ios-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CSFrequency","download_url":"https://codeload.github.com/CSFrequency/firebase-device-store-ios-sdk/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CSFrequency%2Ffirebase-device-store-ios-sdk/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266765383,"owners_count":23980761,"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-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"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":["firebase","firebase-auth","firebase-authentication","firebase-cloud-firestore","firebase-cloud-messaging","firebase-firestore","firebase-messaging","ios-sdk","swift"],"created_at":"2024-09-24T13:48:08.366Z","updated_at":"2026-02-06T12:38:32.681Z","avatar_url":"https://github.com/CSFrequency.png","language":"Ruby","readme":"# Firebase Device Store (iOS SDK)\n\nAutomatically store Device and FCM Token information for Firebase Auth Users in Cloud Firestore.\n\n\u003e This library is a proof of concept, and very much a work in progress.\n\n## Installation\n\nAdd `FirebaseDeviceStore` to your `Podfile`:\n\n```\npod 'FirebaseDeviceStore'\n```\n\n### Objective-C\n\nMake sure you have `use_frameworks!` enabled in your `Podfile`\n\n## Example usage\n\n### Swift\n\nImport the library:\n\n```\nimport FirebaseDeviceStore\n```\n\nInitialise the library:\n\n```\nlet deviceStore = FirebaseDeviceStore.init(app: FirebaseApp.app()!);\n// Subscribe to the device store and ensure that appropriate notification permissions are granted\ndeviceStore.subscribe { (error) in\n  // Handle permission errors here\n}\n```\n\n### Objective-C\n\nImport the library:\n\n```\n#import \"FirebaseDeviceStore-Swift.h\"\n```\n\nInitialise the library:\n\n```\nFirebaseDeviceStore *deviceStore = [[FirebaseDeviceStore alloc] initWithApp:[FIRApp defaultApp]];\n// Subscribe to the device store and ensure that appropriate notification permissions are granted\n[deviceStore subscribe:^(NSError * _Nullable error) {\n  // Handle permission errors here\n}];\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 iPhone')\n  os: string,       // The OS of the device\n  type: 'iOS'\n}\n```\n\n### API (Swift)\n\n#### `FirebaseDeviceStore.init(app: FIRApp, collectionPath: String?)`\n\nCreate a new DeviceStore.\n\nParameters:\n\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#### `signOut(completion: (Error?) -\u003e Void): void`\n\nIndicate to the DeviceStore that the user is about to sign out, and 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\nParameters:\n\n- `completion`: `(Error?) -\u003e Void` a callback handler which will be called with an `Error` if signing out wasn't successful, or `nil` otherwise\n\n#### `subscribe(completion: (Error?) -\u003e Void): void`\n\nSubscribe a device store to the Firebase App. This will:\n\n1. Request appropriate Notification permissions, if they have not already been granted\n2. Subscribe to Firebase Auth and listen to changes in authentication state\n3. Subscribe to Firebase Cloud Messaging and listen to changes in the FCM token\n4. Automatically store device and FCM token information in the Cloud Firestore collection you specify\n\nParameters:\n\n- `completion`: `(Error?) -\u003e Void` a callback handler which will be called with an `Error` if the susbcription wasn't successful, or `nil` otherwise\n\n#### `unsubscribe(): void`\n\nUnsubscribe the device store from the Firebase App.\n\n### API (Objective-C)\n\n#### `[FirebaseDeviceStore initWithApp: FIRApp collectionPath: NSString]`\n\nCreate a new DeviceStore.\n\nParameters:\n\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#### `signOut:(void (^ _Nonnull)(NSError * _Nullable))completion: void`\n\nIndicate to the DeviceStore that the user is about to sign out, and 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\nParameters:\n\n- `completion`: `(void (^ _Nonnull)(NSError * _Nullable))` a callback handler which will return an `Error` if signing out wasn't successful, or `nil` otherwise\n\n#### `subscribe:(void (^ _Nonnull)(NSError * _Nullable))completion: void`\n\nSubscribe a device store to the Firebase App. This will:\n\n1. Request appropriate Notification permissions, if they have not already been granted\n2. Subscribe to Firebase Auth and listen to changes in authentication state\n3. Subscribe to Firebase Cloud Messaging and listen to changes in the FCM token\n4. Automatically store device and FCM token information in the Cloud Firestore collection you specify\n\nParameters:\n\n- `completion`: `(void (^ _Nonnull)(NSError * _Nullable))` a callback handler which will return an `Error` if the susbcription wasn't successful, or `nil` otherwise\n\n#### `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-ios-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcsfrequency%2Ffirebase-device-store-ios-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsfrequency%2Ffirebase-device-store-ios-sdk/lists"}