{"id":15435196,"url":"https://github.com/drptbl/cordova-plugin-firebase-background","last_synced_at":"2025-09-15T08:24:29.937Z","repository":{"id":88033400,"uuid":"90993077","full_name":"drptbl/cordova-plugin-firebase-background","owner":"drptbl","description":null,"archived":false,"fork":false,"pushed_at":"2017-05-16T11:26:13.000Z","size":12952,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-02-27T05:13:28.376Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/drptbl.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":"2017-05-11T15:10:23.000Z","updated_at":"2017-05-11T15:20:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"dffb387e-5020-4cae-a39f-95644d7291c8","html_url":"https://github.com/drptbl/cordova-plugin-firebase-background","commit_stats":{"total_commits":7,"total_committers":2,"mean_commits":3.5,"dds":0.1428571428571429,"last_synced_commit":"6857437bf5d5d5dbb40d43893e3ae410983b7427"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drptbl%2Fcordova-plugin-firebase-background","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drptbl%2Fcordova-plugin-firebase-background/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drptbl%2Fcordova-plugin-firebase-background/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drptbl%2Fcordova-plugin-firebase-background/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/drptbl","download_url":"https://codeload.github.com/drptbl/cordova-plugin-firebase-background/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241819757,"owners_count":20025403,"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":[],"created_at":"2024-10-01T18:43:04.631Z","updated_at":"2025-03-04T09:23:43.366Z","avatar_url":"https://github.com/drptbl.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cordova-plugin-firebase\nThis plugin brings push notifications, analytics, event tracking, crash reporting and more from Google Firebase to your Cordova project!\nAndroid and iOS supported (including iOS 10).\n\n## Installation\nSee npm package for versions - https://www.npmjs.com/package/cordova-plugin-firebase\n\nInstall the plugin by adding it your project's config.xml:\n```\n\u003cplugin name=\"cordova-plugin-firebase\" spec=\"0.1.20\" /\u003e\n```\nor by running:\n```\ncordova plugin add cordova-plugin-firebase@0.1.20 --save\n```\nDownload your Firebase configuration files, GoogleService-Info.plist for ios and google-services.json for android, and place them in the root folder of your cordova project:\n\n```\n- My Project/\n    platforms/\n    plugins/\n    www/\n    config.xml\n    google-services.json       \u003c--\n    GoogleService-Info.plist   \u003c--\n    ...\n```\n\nSee https://support.google.com/firebase/answer/7015592 for details how to download the files from firebase.\n\nThis plugin uses a hook (after prepare) that copies the configuration files to the right place, namely platforms/ios/\\\u003cMy Project\\\u003e/Resources for ios and platforms/android for android.\n\n**Note that the Firebase SDK requires the configuration files to be present and valid, otherwise your app will crash on boot or Firebase features won't work.**\n\n## Changing Notification Icon\nThe plugin will use notification_icon from drawable resources if it exists, otherwise the default app icon will is used.\nTo set a big icon and small icon for notifications, define them through drawable nodes.  \nCreate the required styles.xml files and add the icons to the  \n`\u003cprojectroot\u003e/res/native/android/res/\u003cdrawable-DPI\u003e` folders.  \n\nThe example below uses a png named \"ic_silhouette.png\", the app Icon (@mipmap/icon) and sets a base theme.  \nFrom android version 21 (Lollipop) notifications were changed, needing a seperate setting.  \nIf you only target Lollipop and above, you don't need to setup both.  \nThankfully using the version dependant asset selections, we can make one build/apk supporting all target platforms.  \n`\u003cprojectroot\u003e/res/native/android/res/values/styles.xml`\n```\n\u003c?xml version=\"1.0\" encoding=\"utf-8\" ?\u003e\n\u003cresources\u003e\n    \u003c!-- inherit from the holo theme --\u003e\n    \u003cstyle name=\"AppTheme\" parent=\"android:Theme.Light\"\u003e\n        \u003citem name=\"android:windowDisablePreview\"\u003etrue\u003c/item\u003e\n    \u003c/style\u003e\n    \u003cdrawable name=\"notification_big\"\u003e@mipmap/icon\u003c/drawable\u003e\n    \u003cdrawable name=\"notification_icon\"\u003e@mipmap/icon\u003c/drawable\u003e\n\u003c/resources\u003e\n```\nand  \n`\u003cprojectroot\u003e/res/native/android/res/values-v21/styles.xml`\n```\n\u003c?xml version=\"1.0\" encoding=\"utf-8\" ?\u003e\n\u003cresources\u003e\n    \u003c!-- inherit from the material theme --\u003e\n    \u003cstyle name=\"AppTheme\" parent=\"android:Theme.Material\"\u003e\n        \u003citem name=\"android:windowDisablePreview\"\u003etrue\u003c/item\u003e\n    \u003c/style\u003e\n    \u003cdrawable name=\"notification_big\"\u003e@mipmap/icon\u003c/drawable\u003e\n    \u003cdrawable name=\"notification_icon\"\u003e@drawable/ic_silhouette\u003c/drawable\u003e\n\u003c/resources\u003e\n```\n\n## Notification Colors\n\nOn Android Lollipop and above you can also set the accent color for the notification by adding a color setting.\n\n`\u003cprojectroot\u003e/res/native/android/res/values/colors.xml`\n```\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cresources\u003e\n    \u003ccolor name=\"primary\"\u003e#FFFFFF00\u003c/color\u003e\n    \u003ccolor name=\"primary_dark\"\u003e#FF220022\u003c/color\u003e\n    \u003ccolor name=\"accent\"\u003e#FF00FFFF\u003c/color\u003e\n\u003c/resources\u003e\n```\n\n\n### Notes about PhoneGap Build\n\nHooks does not work with PhoneGap Build. This means you will have to manually make sure the configuration files are included. One way to do that is to make a private fork of this plugin and replace the placeholder config files (see src/ios and src/android) with your actual ones, as well as hard coding your app id and api key in plugin.xml.\n\n\n## Methods\n\n### getToken\n\nGet the device token (id):\n```\nwindow.FirebasePlugin.getToken(function(token) {\n    // save this server-side and use it to push notifications to this device\n    console.log(token);\n}, function(error) {\n    console.error(error);\n});\n```\nNote that token will be null if it has not been established yet\n\n### onTokenRefresh\n\nRegister for token changes:\n```\nwindow.FirebasePlugin.onTokenRefresh(function(token) {\n    // save this server-side and use it to push notifications to this device\n    console.log(token);\n}, function(error) {\n    console.error(error);\n});\n```\nThis is the best way to get a valid token for the device as soon as the token is established\n\n### onNotificationOpen\n\nRegister notification callback:\n```\nwindow.FirebasePlugin.onNotificationOpen(function(notification) {\n    console.log(notification);\n}, function(error) {\n    console.error(error);\n});\n```\nNotification flow:\n\n1. App is in foreground:\n    1. User receives the notification data in the JavaScript callback without any notification on the device itself (this is the normal behaviour of push notifications, it is up to you, the developer, to notify the user)\n2. App is in background:\n    1. User receives the notification message in its device notification bar\n    2. User taps the notification and the app opens\n    3. User receives the notification data in the JavaScript callback\n\nNotification icon on Android:\n\n[Changing notification icon](#changing-notification-icon)\n\n### grantPermission (iOS only)\n\nGrant permission to recieve push notifications (will trigger prompt):\n```\nwindow.FirebasePlugin.grantPermission();\n```\n### hasPermission\n\nCheck permission to recieve push notifications:\n```\nwindow.FirebasePlugin.hasPermission(function(data){\n    console.log(data.isEnabled);\n});\n```\n\n### setBadgeNumber\n\nSet a number on the icon badge:\n```\nwindow.FirebasePlugin.setBadgeNumber(3);\n```\n\nSet 0 to clear the badge\n```\nwindow.FirebasePlugin.setBadgeNumber(0);\n```\n\n### getBadgeNumber\n\nGet icon badge number:\n```\nwindow.FirebasePlugin.getBadgeNumber(function(n) {\n    console.log(n);\n});\n```\n\n### subscribe\n\nSubscribe to a topic:\n```\nwindow.FirebasePlugin.subscribe(\"example\");\n```\n\n### unsubscribe\n\nUnsubscribe from a topic:\n```\nwindow.FirebasePlugin.unsubscribe(\"example\");\n```\n\n### logEvent\n\nLog an event using Analytics:\n```\nwindow.FirebasePlugin.logEvent(\"select_content\", {content_type: \"page_view\", item_id: \"home\"});\n```\n\n### setScreenName\n\nSet the name of the current screen in Analytics:\n```\nwindow.FirebasePlugin.setScreenName(\"Home\");\n```\n\n### setUserId\n\nSet a user id for use in Analytics:\n```\nwindow.FirebasePlugin.setUserId(\"user_id\");\n```\n\n### setUserProperty\n\nSet a user property for use in Analytics:\n```\nwindow.FirebasePlugin.setUserProperty(\"name\", \"value\");\n```\n\n### fetch\n\nFetch Remote Config parameter values for your app:\n```\nwindow.FirebasePlugin.fetch();\n// or, specify the cacheExpirationSeconds\nwindow.FirebasePlugin.fetch(600);\n```\n\n### activateFetched\n\nActivate the Remote Config fetched config:\n```\nwindow.FirebasePlugin.activateFetched(function(activated) {\n    // activated will be true if there was a fetched config activated,\n    // or false if no fetched config was found, or the fetched config was already activated.\n    console.log(activated);\n}, function(error) {\n    console.error(error);\n});\n```\n\n### getValue\n\nRetrieve a Remote Config value:\n```\nwindow.FirebasePlugin.getValue(\"key\", function(value) {\n    console.log(value);\n}, function(error) {\n    console.error(error);\n});\n// or, specify a namespace for the config value\nwindow.FirebasePlugin.getValue(\"key\", \"namespace\", function(value) {\n    console.log(value);\n}, function(error) {\n    console.error(error);\n});\n```\n\n### getByteArray (Android only)\n**NOTE: byte array is only available for SDK 19+**\nRetrieve a Remote Config byte array:\n```\nwindow.FirebasePlugin.getByteArray(\"key\", function(bytes) {\n    // a Base64 encoded string that represents the value for \"key\"\n    console.log(bytes.base64);\n    // a numeric array containing the values of the byte array (i.e. [0xFF, 0x00])\n    console.log(bytes.array);\n}, function(error) {\n    console.error(error);\n});\n// or, specify a namespace for the byte array\nwindow.FirebasePlugin.getByteArray(\"key\", \"namespace\", function(bytes) {\n    // a Base64 encoded string that represents the value for \"key\"\n    console.log(bytes.base64);\n    // a numeric array containing the values of the byte array (i.e. [0xFF, 0x00])\n    console.log(bytes.array);\n}, function(error) {\n    console.error(error);\n});\n```\n\n### getInfo (Android only)\n\nGet the current state of the FirebaseRemoteConfig singleton object:\n```\nwindow.FirebasePlugin.getInfo(function(info) {\n    // the status of the developer mode setting (true/false)\n    console.log(info.configSettings.developerModeEnabled);\n    // the timestamp (milliseconds since epoch) of the last successful fetch\n    console.log(info.fetchTimeMillis);\n    // the status of the most recent fetch attempt (int)\n    console.log(info.lastFetchStatus);\n}, function(error) {\n    console.error(error);\n});\n```\n\n### setConfigSettings (Android only)\n\nChange the settings for the FirebaseRemoteConfig object's operations:\n```\nvar settings = {\n    developerModeEnabled: true\n}\nwindow.FirebasePlugin.setConfigSettings(settings);\n```\n\n### setDefaults (Android only)\n\nSet defaults in the Remote Config:\n```\n// define defaults\nvar defaults = {\n    // map property name to value in Remote Config defaults\n    mLong: 1000,\n    mString: 'hello world',\n    mDouble: 3.14,\n    mBoolean: true,\n    // map \"mBase64\" to a Remote Config byte array represented by a Base64 string\n    // Note: the Base64 string is in an array in order to differentiate from a string config value\n    mBase64: [\"SGVsbG8gV29ybGQ=\"],\n    // map \"mBytes\" to a Remote Config byte array represented by a numeric array\n    mBytes: [0xFF, 0x00]\n}\n// set defaults\nwindow.FirebasePlugin.setDefaults(defaults);\n// or, specify a namespace\nwindow.FirebasePlugin.setDefaults(defaults, \"namespace\");\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrptbl%2Fcordova-plugin-firebase-background","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrptbl%2Fcordova-plugin-firebase-background","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrptbl%2Fcordova-plugin-firebase-background/lists"}