cordova-plugin-firebase
Advanced tools
Comparing version 0.1.19 to 0.1.20
@@ -11,3 +11,3 @@ { | ||
"name": "cordova-plugin-firebase", | ||
"version": "0.1.19", | ||
"version": "0.1.20", | ||
"description": "Cordova plugin for Google Firebase", | ||
@@ -14,0 +14,0 @@ "cordova": { |
@@ -10,7 +10,7 @@ # cordova-plugin-firebase | ||
``` | ||
<plugin name="cordova-plugin-firebase" spec="0.1.19" /> | ||
<plugin name="cordova-plugin-firebase" spec="0.1.20" /> | ||
``` | ||
or by running: | ||
``` | ||
cordova plugin add cordova-plugin-firebase@0.1.19 --save | ||
cordova plugin add cordova-plugin-firebase@0.1.20 --save | ||
``` | ||
@@ -36,2 +36,53 @@ Download 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: | ||
## Changing Notification Icon | ||
The plugin will use notification_icon from drawable resources if it exists, otherwise the default app icon will is used. | ||
To set a big icon and small icon for notifications, define them through drawable nodes. | ||
Create the required styles.xml files and add the icons to the | ||
`<projectroot>/res/native/android/res/<drawable-DPI>` folders. | ||
The example below uses a png named "ic_silhouette.png", the app Icon (@mipmap/icon) and sets a base theme. | ||
From android version 21 (Lollipop) notifications were changed, needing a seperate setting. | ||
If you only target Lollipop and above, you don't need to setup both. | ||
Thankfully using the version dependant asset selections, we can make one build/apk supporting all target platforms. | ||
`<projectroot>/res/native/android/res/values/styles.xml` | ||
``` | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<resources> | ||
<!-- inherit from the holo theme --> | ||
<style name="AppTheme" parent="android:Theme.Light"> | ||
<item name="android:windowDisablePreview">true</item> | ||
</style> | ||
<drawable name="notification_big">@mipmap/icon</drawable> | ||
<drawable name="notification_icon">@mipmap/icon</drawable> | ||
</resources> | ||
``` | ||
and | ||
`<projectroot>/res/native/android/res/values-v21/styles.xml` | ||
``` | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<resources> | ||
<!-- inherit from the material theme --> | ||
<style name="AppTheme" parent="android:Theme.Material"> | ||
<item name="android:windowDisablePreview">true</item> | ||
</style> | ||
<drawable name="notification_big">@mipmap/icon</drawable> | ||
<drawable name="notification_icon">@drawable/ic_silhouette</drawable> | ||
</resources> | ||
``` | ||
## Notification Colors | ||
On Android Lollipop and above you can also set the accent color for the notification by adding a color setting. | ||
`<projectroot>/res/native/android/res/values/colors.xml` | ||
``` | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="primary">#FFFFFF00</color> | ||
<color name="primary_dark">#FF220022</color> | ||
<color name="accent">#FF00FFFF</color> | ||
</resources> | ||
``` | ||
### Notes about PhoneGap Build | ||
@@ -91,3 +142,3 @@ | ||
The plugin will look for and use notification_icon in drawable resources if it exists, otherwise the default app icon will is used. | ||
[Changing notification icon](#changing-notification-icon) | ||
@@ -100,3 +151,11 @@ ### grantPermission (iOS only) | ||
``` | ||
### hasPermission | ||
Check permission to recieve push notifications: | ||
``` | ||
window.FirebasePlugin.hasPermission(function(data){ | ||
console.log(data.isEnabled); | ||
}); | ||
``` | ||
### setBadgeNumber | ||
@@ -141,5 +200,12 @@ | ||
``` | ||
window.FirebasePlugin.logEvent("page_view", {page: "dashboard"}); | ||
window.FirebasePlugin.logEvent("select_content", {content_type: "page_view", item_id: "home"}); | ||
``` | ||
### setScreenName | ||
Set the name of the current screen in Analytics: | ||
``` | ||
window.FirebasePlugin.setScreenName("Home"); | ||
``` | ||
### setUserId | ||
@@ -159,3 +225,3 @@ | ||
### fetch (Android only) | ||
### fetch | ||
@@ -169,3 +235,3 @@ Fetch Remote Config parameter values for your app: | ||
### activateFetched (Android only) | ||
### activateFetched | ||
@@ -183,3 +249,3 @@ Activate the Remote Config fetched config: | ||
### getValue (Android only) | ||
### getValue | ||
@@ -186,0 +252,0 @@ Retrieve a Remote Config value: |
@@ -66,6 +66,6 @@ #!/usr/bin/env node | ||
// strip non-default value | ||
strings = strings.replace(new RegExp('<string name="google_app_id">([^\@<]+?)</string>', "i"), '') | ||
strings = strings.replace(new RegExp('<string name="google_app_id">([^\@<]+?)<\/string>', "i"), '') | ||
// strip non-default value | ||
strings = strings.replace(new RegExp('<string name="google_api_key">([^\@<]+?)</string>', "i"), '') | ||
strings = strings.replace(new RegExp('<string name="google_api_key">([^\@<]+?)<\/string>', "i"), '') | ||
@@ -76,6 +76,6 @@ // strip empty lines | ||
// replace the default value | ||
strings = strings.replace(new RegExp('<string name="google_app_id">([^<]+?)</string>', "i"), '<string name="google_app_id">' + json.client[0].client_info.mobilesdk_app_id + '</string>') | ||
strings = strings.replace(new RegExp('<string name="google_app_id">([^<]+?)<\/string>', "i"), '<string name="google_app_id">' + json.client[0].client_info.mobilesdk_app_id + '</string>') | ||
// replace the default value | ||
strings = strings.replace(new RegExp('<string name="google_api_key">([^<]+?)</string>', "i"), '<string name="google_api_key">' + json.client[0].api_key[0].current_key + '</string>') | ||
strings = strings.replace(new RegExp('<string name="google_api_key">([^<]+?)<\/string>', "i"), '<string name="google_api_key">' + json.client[0].api_key[0].current_key + '</string>') | ||
@@ -82,0 +82,0 @@ fs.writeFileSync("platforms/android/res/values/strings.xml", strings); |
@@ -55,2 +55,8 @@ exports.getInstanceId = function(success, error) { | ||
exports.setScreenName = function(name, success, error) { | ||
if (typeof success === 'function') { | ||
success(); | ||
} | ||
}; | ||
exports.setUserId = function(id, success, error) { | ||
@@ -57,0 +63,0 @@ if (typeof success === 'function') { |
@@ -23,2 +23,6 @@ var exec = require('cordova/exec'); | ||
exports.hasPermission = function(success, error) { | ||
exec(success, error, "FirebasePlugin", "hasPermission", []); | ||
}; | ||
exports.setBadgeNumber = function(number, success, error) { | ||
@@ -44,2 +48,6 @@ exec(success, error, "FirebasePlugin", "setBadgeNumber", [number]); | ||
exports.setScreenName = function(name, success, error) { | ||
exec(success, error, "FirebasePlugin", "setScreenName", [name]); | ||
}; | ||
exports.setUserId = function(id, success, error) { | ||
@@ -46,0 +54,0 @@ exec(success, error, "FirebasePlugin", "setUserId", [id]); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
30866996
256
330