Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.idea
/src/windows.old
/src/windows/Microsoft.Toolkit.Uwp.Notifications.*
/src/windows/**/.vs
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Changelog
---------
#### Version 0.9.4 (27.11.2020)
- Add namespace to provider authority to prevent crashes on Android.

#### Version 0.9.3 (09.05.2019)
- Add namespace to provider authority to prevent crashes on Android.
Expand Down
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ __Known issues__

Please report bugs or missing features!

## Installation

To install the latest version:

$ cordova plugin add https://github.com/hamzayanni/cordova-plugin-local-notifications.git


## Basics

Expand Down Expand Up @@ -514,14 +520,6 @@ See the sample app for how to use them.
| clearAll | isPresent | getScheduledIds | getTriggered | setDefaults |
| cancel | isScheduled | getTriggeredIds | addActions | on |


## Installation

To install the latest version:

$ cordova plugin add https://github.com/Steffaan/cordova-plugin-local-notifications.git


## License

This software is released under the [Apache 2.0 License][apache2_license].
Expand Down
49 changes: 27 additions & 22 deletions src/android/notification/Manager.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import static de.appplant.cordova.plugin.notification.Notification.PREF_KEY_ID;
import static de.appplant.cordova.plugin.notification.Notification.Type.TRIGGERED;
import de.appplant.cordova.plugin.notification.Options;
import de.appplant.cordova.plugin.notification.util.AssetUtil;

/**
* Central way to access all or single local notifications set by specific
Expand All @@ -72,6 +73,9 @@ public final class Manager {
// The application context
private Context context;

// Asset util instance
private final AssetUtil assets;

/**
* Constructor
*
Expand All @@ -80,6 +84,7 @@ public final class Manager {
private Manager(Context context) {
this.context = context;
//createDefaultChannel();
assets = AssetUtil.getInstance(context);
}

/**
Expand Down Expand Up @@ -113,7 +118,7 @@ public Notification schedule (Request request, Class<?> receiver) {
return toast;
}

/**
/**
* TODO: temporary
*/
@SuppressLint("WrongConstant")
Expand All @@ -126,8 +131,10 @@ public void createChannel(Options options) {

NotificationChannel channel = mgr.getNotificationChannel(options.getChannel());

if (channel != null)
return;
if (channel != null) {
channel = null;
mgr.deleteNotificationChannel(options.getChannel());
}

switch (options.getPrio()) {
case PRIORITY_MIN:
Expand All @@ -149,28 +156,26 @@ public void createChannel(Options options) {

channel = new NotificationChannel(
options.getChannel(), options.getChannelDescription(), importance);
if(!options.isSilent() && importance > IMPORTANCE_DEFAULT) channel.setBypassDnd(true);
if(!options.isWithoutLights()) channel.enableLights(true);
if(options.isWithVibration()) {
channel.enableVibration(true);
} else {
channel.setVibrationPattern(new long[]{ 0 });
channel.enableVibration(true);
}
channel.setLightColor(options.getLedColor());
if(!options.isSilent() && importance > IMPORTANCE_DEFAULT) channel.setBypassDnd(true);
if(!options.isWithoutLights()) channel.enableLights(true);
if(options.isWithVibration()) {
channel.enableVibration(true);
} else {
channel.setVibrationPattern(new long[]{ 0 });
channel.enableVibration(true);
}
channel.setLightColor(options.getLedColor());
if(options.isWithoutSound()) {
channel.setSound(null, null);
} else {
AudioAttributes audioAttributes = new AudioAttributes.Builder()
channel.setSound(null, null);
} else {
AudioAttributes audioAttributes = new AudioAttributes.Builder()
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
.setUsage(AudioAttributes.USAGE_NOTIFICATION).build();

if(options.isWithDefaultSound()) {
channel.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION), audioAttributes);
} else {
channel.setSound(options.getSound(), audioAttributes);
}
}

SharedPreferences sharedpreferences = this.context.getSharedPreferences("ADHAN", Context.MODE_PRIVATE);
String sound = sharedpreferences.getString("sound", "file://assets/audio/adhan_makkah.wav");
channel.setSound(assets.parse(sound), audioAttributes);
}

mgr.createNotificationChannel(channel);
}
Expand Down