Skip to content

Commit

Permalink
fix possible missing permissions and avoid crash on API < 19
Browse files Browse the repository at this point in the history
trying to fix again

adds warning to readme

revert shortcutbadger version
  • Loading branch information
juliocbcotta committed Sep 22, 2016
1 parent 3a83ef1 commit 3fce1b8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Note that token will be null if it has not been established yet

### onNotificationOpen

Register notification callback:
Register notification callback:
```
window.FirebasePlugin.onNotificationOpen(function(notification) {
console.error(notification);
Expand Down Expand Up @@ -173,7 +173,7 @@ window.FirebasePlugin.getValue("key", "namespace", function(value) {
```

### getByteArray (Android only)

### The option with byte array in only available for SDK +19!!
Retrieve a Remote Config byte array:
```
window.FirebasePlugin.getByteArray("key", function(bytes) {
Expand Down
7 changes: 6 additions & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<plugin id="cordova-plugin-firebase" version="0.1.12"
<plugin id="cordova-plugin-firebase" version="0.1.12"
xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android">
<name>Google Firebase Plugin</name>
Expand All @@ -26,6 +26,11 @@ xmlns:android="http://schemas.android.com/apk/res/android">
<config-file parent="/resources" target="res/values/strings.xml">
<string name="google_api_key">@string/google_api_key</string>
</config-file>
<config-file target="AndroidManifest.xml" parent="/*">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
</config-file>
<config-file target="AndroidManifest.xml" parent="/manifest/application">
<service android:name="org.apache.cordova.firebase.FirebasePluginMessagingService">
<intent-filter>
Expand Down
6 changes: 4 additions & 2 deletions src/android/FirebasePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.util.Base64;
import android.util.Log;
import android.os.Bundle;
import android.content.Context;
import android.content.SharedPreferences;

import com.google.android.gms.tasks.OnCompleteListener;
Expand Down Expand Up @@ -319,7 +319,9 @@ public void run() {
: FirebaseRemoteConfig.getInstance().getByteArray(key, namespace);
JSONObject object = new JSONObject();
object.put("base64", Base64.encodeToString(bytes, Base64.DEFAULT));
object.put("array", new JSONArray(bytes));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
object.put("array", new JSONArray(bytes));
}
callbackContext.success(object);
} catch (Exception e) {
callbackContext.error(e.getMessage());
Expand Down
2 changes: 1 addition & 1 deletion src/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ repositories {
}
dependencies {
compile 'me.leolin:ShortcutBadger:1.1.4@aar'
}
}

0 comments on commit 3fce1b8

Please sign in to comment.