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
2 changes: 1 addition & 1 deletion local-notifications/CapacitorLocalNotifications.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Pod::Spec.new do |s|
s.author = package['author']
s.source = { :git => 'https://github.com/ionic-team/capacitor-plugins.git', :tag => package['name'] + '@' + package['version'] }
s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}', 'local-notifications/ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
s.ios.deployment_target = '14.0'
s.ios.deployment_target = '16.2'
s.dependency 'Capacitor'
s.swift_version = '5.1'
end
2 changes: 1 addition & 1 deletion local-notifications/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PackageDescription

let package = Package(
name: "CapacitorLocalNotifications",
platforms: [.iOS(.v14)],
platforms: [.iOS(.v16)],
products: [
.library(
name: "CapacitorLocalNotifications",
Expand Down
223 changes: 199 additions & 24 deletions local-notifications/README.md

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions local-notifications/android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,22 @@
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
</intent-filter>
</receiver>
<!-- Receiver pour callback quand le timer se termine -->
<receiver
android:name="com.capacitorjs.plugins.localnotifications.TimerEndReceiver"
android:exported="false" />

<!-- Service foreground pour mise à jour de la progression du timer en arrière-plan -->
<service
android:name="com.capacitorjs.plugins.localnotifications.TimerProgressService"
android:enabled="true"
android:exported="false"
android:foregroundServiceType="specialUse" />
</application>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE"/>
<uses-permission android:name="android.permission.VIBRATE"/>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ public class LocalNotification {
private LocalNotificationSchedule schedule;
private String channelId;
private String source;

// Chronometer support for native timer display
private boolean chronometerEnabled;
private boolean chronometerCountDown;
private long chronometerWhen;
private boolean silentUpdate;

public String getTitle() {
return title;
Expand Down Expand Up @@ -203,6 +209,43 @@ public void setChannelId(String channelId) {
this.channelId = channelId;
}

// Chronometer getters and setters
public boolean isChronometerEnabled() {
return chronometerEnabled;
}

public void setChronometerEnabled(boolean chronometerEnabled) {
this.chronometerEnabled = chronometerEnabled;
}

public boolean isChronometerCountDown() {
return chronometerCountDown;
}

public void setChronometerCountDown(boolean chronometerCountDown) {
this.chronometerCountDown = chronometerCountDown;
}

public long getChronometerWhen() {
return chronometerWhen;
}

public void setChronometerWhen(long chronometerWhen) {
this.chronometerWhen = chronometerWhen;
}

public boolean isSilentUpdate() {
return silentUpdate;
}

public void setSilentUpdate(boolean silentUpdate) {
this.silentUpdate = silentUpdate;
}

public boolean hasChronometer() {
return chronometerEnabled;
}

/**
* Build list of the notifications from remote plugin call
*/
Expand Down Expand Up @@ -270,6 +313,19 @@ public static LocalNotification buildNotificationFromJSObject(JSObject jsonObjec
localNotification.setExtra(jsonObject.getJSObject("extra"));
localNotification.setOngoing(jsonObject.getBoolean("ongoing", false));
localNotification.setAutoCancel(jsonObject.getBoolean("autoCancel", true));
localNotification.setSilentUpdate(jsonObject.getBoolean("silentUpdate", false));

// Parse chronometer settings
JSObject chronometerObj = jsonObject.getJSObject("chronometer");
if (chronometerObj != null) {
localNotification.setChronometerEnabled(chronometerObj.getBoolean("enabled", false));
localNotification.setChronometerCountDown(chronometerObj.getBoolean("countDown", false));
// Use optLong to avoid JSONException - returns 0 if not found
long when = chronometerObj.optLong("when", 0);
if (when > 0) {
localNotification.setChronometerWhen(when);
}
}

try {
JSONArray inboxList = jsonObject.getJSONArray("inboxList");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,29 @@ private void buildNotification(NotificationManagerCompat notificationManager, Lo
mBuilder.setVisibility(NotificationCompat.VISIBILITY_PRIVATE);
mBuilder.setOnlyAlertOnce(true);

// Chronometer support for native timer display
if (localNotification.hasChronometer()) {
mBuilder.setUsesChronometer(true);

long when = localNotification.getChronometerWhen();
if (when > 0) {
mBuilder.setWhen(when);
}

// API 24+ for countdown mode
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && localNotification.isChronometerCountDown()) {
mBuilder.setChronometerCountDown(true);
}
}

// Silent update support - don't make sound/vibrate on update
if (localNotification.isSilentUpdate()) {
mBuilder.setOnlyAlertOnce(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
mBuilder.setSilent(true);
}
}

mBuilder.setSmallIcon(localNotification.getSmallIcon(context, getDefaultSmallIcon(context)));
mBuilder.setLargeIcon(localNotification.getLargeIcon(context));

Expand Down
Loading