Java Code Examples for com.getcapacitor.PluginCall#unavailable()

The following examples show how to use com.getcapacitor.PluginCall#unavailable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PushNotifications.java    From OsmGo with MIT License 6 votes vote down vote up
@PluginMethod()
public void listChannels(PluginCall call) {
  if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
    List<NotificationChannel> notificationChannels = notificationManager.getNotificationChannels();
    JSArray channels = new JSArray();
    for (NotificationChannel notificationChannel : notificationChannels) {
      JSObject channel = new JSObject();
      channel.put(CHANNEL_ID, notificationChannel.getId());
      channel.put(CHANNEL_NAME, notificationChannel.getName());
      channel.put(CHANNEL_DESCRIPTION, notificationChannel.getDescription());
      channel.put(CHANNEL_IMPORTANCE, notificationChannel.getImportance());
      channel.put(CHANNEL_VISIBILITY, notificationChannel.getLockscreenVisibility());
      Log.d(getLogTag(), "visibility " + notificationChannel.getLockscreenVisibility());
      Log.d(getLogTag(), "importance " + notificationChannel.getImportance());
      channels.put(channel);
    }
    JSObject result = new JSObject();
    result.put("channels", channels);
    call.success(result);
  } else {
    call.unavailable();
  }
}
 
Example 2
Source File: PushNotifications.java    From OsmGo with MIT License 5 votes vote down vote up
@PluginMethod()
public void createChannel(PluginCall call) {
  if (android.os.Build.VERSION.SDK_INT  >= android.os.Build.VERSION_CODES.O) {
    JSObject channel = new JSObject();
    channel.put(CHANNEL_ID, call.getString(CHANNEL_ID));
    channel.put(CHANNEL_NAME, call.getString(CHANNEL_NAME));
    channel.put(CHANNEL_DESCRIPTION, call.getString(CHANNEL_DESCRIPTION, ""));
    channel.put(CHANNEL_VISIBILITY,  call.getInt(CHANNEL_VISIBILITY, NotificationCompat.VISIBILITY_PUBLIC));
    channel.put(CHANNEL_IMPORTANCE, call.getInt(CHANNEL_IMPORTANCE));
    createChannel(channel);
    call.success();
  } else {
    call.unavailable();
  }
}
 
Example 3
Source File: PushNotifications.java    From OsmGo with MIT License 5 votes vote down vote up
@PluginMethod()
public void deleteChannel(PluginCall call) {
  if (android.os.Build.VERSION.SDK_INT  >= android.os.Build.VERSION_CODES.O) {
    String channelId = call.getString("id");
    notificationManager.deleteNotificationChannel(channelId);
    call.success();
  } else {
    call.unavailable();
  }
}