Skip to content

Commit

Permalink
fix(local-notifications): requestPermissions and checkPermissions ret…
Browse files Browse the repository at this point in the history
…urn if enabled (#494)
  • Loading branch information
jcesarmobile committed Jun 24, 2021
1 parent 8b20a24 commit 555bb1f
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,28 @@ public void listChannels(PluginCall call) {
notificationChannelManager.listChannels(call);
}

@PluginMethod
public void checkPermissions(PluginCall call) {
JSObject permissionsResultJSON = new JSObject();
permissionsResultJSON.put("display", getNotificationPermissionText());
call.resolve(permissionsResultJSON);
}

@PluginMethod
public void requestPermissions(PluginCall call) {
JSObject permissionsResultJSON = new JSObject();
permissionsResultJSON.put("display", getNotificationPermissionText());
call.resolve(permissionsResultJSON);
}

private String getNotificationPermissionText() {
if (manager.areNotificationsEnabled()) {
return "granted";
} else {
return "denied";
}
}

public static void fireReceived(JSObject notification) {
LocalNotificationsPlugin localNotificationsPlugin = LocalNotificationsPlugin.getLocalNotificationsInstance();
if (localNotificationsPlugin != null) {
Expand Down

0 comments on commit 555bb1f

Please sign in to comment.