Commit 0793559b by Chris Yuen Committed by Sebastián Katzer

Allow option to setVibrate() on Android (#1356)

parent 9f317fc2
...@@ -118,6 +118,7 @@ public class Builder { ...@@ -118,6 +118,7 @@ public class Builder {
Uri sound = options.getSoundUri(); Uri sound = options.getSoundUri();
int smallIcon = options.getSmallIcon(); int smallIcon = options.getSmallIcon();
int ledColor = options.getLedColor(); int ledColor = options.getLedColor();
long[] vibrate = options.getVibrate();
NotificationCompat.Builder builder; NotificationCompat.Builder builder;
builder = new NotificationCompat.Builder(context) builder = new NotificationCompat.Builder(context)
...@@ -138,6 +139,10 @@ public class Builder { ...@@ -138,6 +139,10 @@ public class Builder {
builder.setSound(sound); builder.setSound(sound);
} }
if (vibrate != null) {
builder.setVibrate(vibrate);
}
if (smallIcon == 0) { if (smallIcon == 0) {
builder.setSmallIcon(options.getIcon()); builder.setSmallIcon(options.getIcon());
} else { } else {
......
...@@ -31,6 +31,7 @@ import android.support.v4.app.NotificationCompat; ...@@ -31,6 +31,7 @@ import android.support.v4.app.NotificationCompat;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import org.json.JSONArray;
import java.util.Date; import java.util.Date;
...@@ -318,6 +319,21 @@ public class Options { ...@@ -318,6 +319,21 @@ public class Options {
return uri; return uri;
} }
public long[] getVibrate() {
JSONArray array = options.optJSONArray("vibrate");
if (array == null)
return null;
long[] rv = new long[array.length()];
for (int i = 0; i < array.length(); i++) {
rv[i] = array.optInt(i);
}
return rv;
}
/** /**
* Icon bitmap for the local notification. * Icon bitmap for the local notification.
*/ */
......
...@@ -71,6 +71,7 @@ exports.applyPlatformSpecificOptions = function () { ...@@ -71,6 +71,7 @@ exports.applyPlatformSpecificOptions = function () {
defaults.ledOnTime = undefined; defaults.ledOnTime = undefined;
defaults.ledOffTime = undefined; defaults.ledOffTime = undefined;
defaults.color = undefined; defaults.color = undefined;
defaults.vibrate = undefined;
break; break;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment