@greatdayhr/capacitor-datetime-setting 2.0.1 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +84 -3
- package/android/src/main/java/com/datetimesetting/DateTimeSettingPlugin.java +16 -0
- package/dist/esm/definitions.d.ts +26 -0
- package/dist/esm/definitions.d.ts.map +1 -1
- package/dist/esm/web.d.ts +3 -0
- package/dist/esm/web.d.ts.map +1 -1
- package/dist/esm/web.js +3 -0
- package/dist/plugin.cjs.js +3 -0
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +3 -0
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/AutoDateTimeDetector.swift +66 -0
- package/ios/Plugin/DateTimeSettingPlugin.swift +27 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,8 +14,8 @@ Capacitor plugin for comprehensive date/time management on iOS. Cloned from [dat
|
|
|
14
14
|
- Network-optimized with caching and offline fallback
|
|
15
15
|
|
|
16
16
|
**Platform Support:**
|
|
17
|
-
- ✅ **iOS**: Full implementation (
|
|
18
|
-
-
|
|
17
|
+
- ✅ **iOS**: Full implementation (12 methods)
|
|
18
|
+
- ✅ **Android**: 2 methods (`isDateTimeChanged`, `isDateTimeChangedSimple`)
|
|
19
19
|
- ❌ **Web**: Not supported
|
|
20
20
|
|
|
21
21
|
## Installation
|
|
@@ -27,6 +27,74 @@ npx cap sync ios
|
|
|
27
27
|
|
|
28
28
|
## API
|
|
29
29
|
|
|
30
|
+
### Simple Change Detection
|
|
31
|
+
|
|
32
|
+
#### `isDateTimeChanged()`
|
|
33
|
+
|
|
34
|
+
Check if date/time has been manually changed. Returns `true` if auto date/time is disabled (inverse of auto time enabled).
|
|
35
|
+
|
|
36
|
+
This is a simple wrapper from date_change_checker source that provides a quick boolean check.
|
|
37
|
+
|
|
38
|
+
**Returns:** `Promise<{ changed: boolean }>`
|
|
39
|
+
|
|
40
|
+
**Platform Support:**
|
|
41
|
+
- ✅ iOS
|
|
42
|
+
- ✅ Android
|
|
43
|
+
|
|
44
|
+
**Example:**
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import { DateTimeSetting } from '@greatdayhr/capacitor-datetime-setting';
|
|
48
|
+
|
|
49
|
+
const result = await DateTimeSetting.isDateTimeChanged();
|
|
50
|
+
if (result.changed) {
|
|
51
|
+
console.log('Auto date/time is disabled - might be manually changed');
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
#### `isDateTimeChangedSimple()`
|
|
58
|
+
|
|
59
|
+
Simple NTP-based check if date/time has been manually changed. Uses basic 30-second threshold comparison without caching.
|
|
60
|
+
|
|
61
|
+
This method matches Flutter plugin behavior exactly and provides a simpler, more predictable alternative to `isDateTimeChanged()`.
|
|
62
|
+
|
|
63
|
+
**Platform behavior:**
|
|
64
|
+
- **iOS**: Compares device time with NTP server (30s threshold)
|
|
65
|
+
- **Android**: Checks Settings.Global.AUTO_TIME
|
|
66
|
+
- Returns `true` if auto time is disabled or network fails (conservative)
|
|
67
|
+
|
|
68
|
+
**Returns:** `Promise<{ changed: boolean }>`
|
|
69
|
+
|
|
70
|
+
**Platform Support:**
|
|
71
|
+
- ✅ iOS
|
|
72
|
+
- ✅ Android
|
|
73
|
+
|
|
74
|
+
**Example:**
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
import { DateTimeSetting } from '@greatdayhr/capacitor-datetime-setting';
|
|
78
|
+
|
|
79
|
+
const result = await DateTimeSetting.isDateTimeChangedSimple();
|
|
80
|
+
if (result.changed) {
|
|
81
|
+
console.log('Auto date/time is disabled');
|
|
82
|
+
// This result matches Flutter plugin behavior exactly
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**When to use:**
|
|
87
|
+
- ✅ When you need consistent behavior with Flutter `date_change_checker`
|
|
88
|
+
- ✅ When you prefer simple, predictable NTP check without caching
|
|
89
|
+
- ✅ When you want conservative detection (fails closed on network errors)
|
|
90
|
+
|
|
91
|
+
**When to use `isDateTimeChanged()` instead:**
|
|
92
|
+
- ✅ When you need faster responses (uses 30s cache)
|
|
93
|
+
- ✅ When you need offline fallback with timezone checks
|
|
94
|
+
- ✅ When you want battery-optimized network monitoring
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
30
98
|
### Date/Time Change Detection
|
|
31
99
|
|
|
32
100
|
#### `detectDateTimeChange()`
|
|
@@ -421,7 +489,20 @@ This plugin is not supported on web. All methods will throw "Not implemented on
|
|
|
421
489
|
|
|
422
490
|
See [CHANGELOG.md](CHANGELOG.md) for detailed version history.
|
|
423
491
|
|
|
424
|
-
**Latest version (2.
|
|
492
|
+
**Latest version (2.1.0)**:
|
|
493
|
+
- ✨ Added `isDateTimeChangedSimple()` method for iOS and Android
|
|
494
|
+
- 🎯 Simple NTP-based detection matching Flutter plugin behavior
|
|
495
|
+
- 📱 iOS: 30-second threshold check without caching
|
|
496
|
+
- 📱 Android: Settings.Global.AUTO_TIME check
|
|
497
|
+
- 🔧 Total: 12 methods (iOS), 2 methods (Android)
|
|
498
|
+
|
|
499
|
+
**Previous version (2.0.1)**:
|
|
500
|
+
- ✨ Added `isDateTimeChanged()` method for iOS and Android
|
|
501
|
+
- 🔧 Simple wrapper returning inverse of `isAutoDateTimeEnabled`
|
|
502
|
+
- 📱 Android now has 1 implemented method
|
|
503
|
+
- 🎯 Total: 11 methods (iOS), 1 method (Android)
|
|
504
|
+
|
|
505
|
+
**Previous version (2.0.0)**:
|
|
425
506
|
- ✨ Cloned all iOS functionality from date_change_checker Flutter plugin
|
|
426
507
|
- ✨ Added comprehensive date/time change detection methods (4 methods)
|
|
427
508
|
- ✨ Added automatic user notifications for date/time changes (iOS)
|
|
@@ -40,6 +40,22 @@ public class DateTimeSettingPlugin extends Plugin {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Simple check if date/time has been manually changed.
|
|
45
|
+
* Uses Settings.Global.AUTO_TIME check (same as isDateTimeChanged).
|
|
46
|
+
*
|
|
47
|
+
* This method provides consistent behavior with iOS simple NTP check.
|
|
48
|
+
* Android uses Settings check instead of NTP.
|
|
49
|
+
*
|
|
50
|
+
* @since 2.1.0
|
|
51
|
+
*/
|
|
52
|
+
@PluginMethod
|
|
53
|
+
public void isDateTimeChangedSimple(PluginCall call) {
|
|
54
|
+
// Android: Reuse existing simple Settings check
|
|
55
|
+
// This matches Flutter plugin behavior where Android uses Settings
|
|
56
|
+
isDateTimeChanged(call);
|
|
57
|
+
}
|
|
58
|
+
|
|
43
59
|
/**
|
|
44
60
|
* Helper method to check if automatic date/time is enabled.
|
|
45
61
|
* Uses Settings.Global.AUTO_TIME.
|
|
@@ -52,6 +52,32 @@ export interface DateTimeSettingPlugin {
|
|
|
52
52
|
isDateTimeChanged(): Promise<{
|
|
53
53
|
changed: boolean;
|
|
54
54
|
}>;
|
|
55
|
+
/**
|
|
56
|
+
* Simple NTP-based check if date/time has been manually changed.
|
|
57
|
+
* Uses basic 30-second threshold comparison without caching.
|
|
58
|
+
*
|
|
59
|
+
* This method matches Flutter plugin behavior exactly and provides
|
|
60
|
+
* a simpler, more predictable alternative to isDateTimeChanged().
|
|
61
|
+
*
|
|
62
|
+
* Platform behavior:
|
|
63
|
+
* - iOS: Compares device time with NTP server (30s threshold)
|
|
64
|
+
* - Android: Checks Settings.Global.AUTO_TIME
|
|
65
|
+
* - Returns true if auto time is disabled or network fails (conservative)
|
|
66
|
+
*
|
|
67
|
+
* @returns Promise with boolean indicating if auto time is disabled
|
|
68
|
+
* @since 2.1.0
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* const result = await DateTimeSetting.isDateTimeChangedSimple();
|
|
73
|
+
* if (result.changed) {
|
|
74
|
+
* console.log('Auto date/time is disabled');
|
|
75
|
+
* }
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
isDateTimeChangedSimple(): Promise<{
|
|
79
|
+
changed: boolean;
|
|
80
|
+
}>;
|
|
55
81
|
/**
|
|
56
82
|
* Detects if the device's date/time has been manually changed.
|
|
57
83
|
* Uses network time comparison for accuracy when available.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACjC;;OAEG;IACH,UAAU,EAAE,UAAU,GAAG,UAAU,GAAG,UAAU,GAAG,aAAa,CAAC;IAEjE;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,qBAAqB,EAAE,OAAO,CAAC;IAE/B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,qBAAqB;IAClC;;;;;;;;;;;;;;;;OAgBG;IACH,iBAAiB,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACjC;;OAEG;IACH,UAAU,EAAE,UAAU,GAAG,UAAU,GAAG,UAAU,GAAG,aAAa,CAAC;IAEjE;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,qBAAqB,EAAE,OAAO,CAAC;IAE/B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,WAAW,EAAE,M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EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC,CAAC;IAE5D;;;;;;;;;;;OAWG;IACH,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAClC"}
|
package/dist/esm/web.d.ts
CHANGED
|
@@ -4,6 +4,9 @@ export declare class DateTimeSettingWeb extends WebPlugin implements DateTimeSet
|
|
|
4
4
|
isDateTimeChanged(): Promise<{
|
|
5
5
|
changed: boolean;
|
|
6
6
|
}>;
|
|
7
|
+
isDateTimeChangedSimple(): Promise<{
|
|
8
|
+
changed: boolean;
|
|
9
|
+
}>;
|
|
7
10
|
detectDateTimeChange(): Promise<{
|
|
8
11
|
changed: boolean;
|
|
9
12
|
}>;
|
package/dist/esm/web.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,KAAK,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAEjF,qBAAa,kBAAmB,SAAQ,SAAU,YAAW,qBAAqB;IACxE,iBAAiB,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,KAAK,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAEjF,qBAAa,kBAAmB,SAAQ,SAAU,YAAW,qBAAqB;IACxE,iBAAiB,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAIlD,uBAAuB,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAKxD,oBAAoB,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAIrD,iCAAiC,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAIlE,oBAAoB,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAIrD,8BAA8B,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAK/D,YAAY,IAAI,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAI9C,kBAAkB,IAAI,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAIpD,kBAAkB,CAAC,OAAO,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAKlF,kBAAkB,CAAC,OAAO,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjE,kBAAkB,IAAI,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IAI3D,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;CAGvC"}
|
package/dist/esm/web.js
CHANGED
|
@@ -3,6 +3,9 @@ export class DateTimeSettingWeb extends WebPlugin {
|
|
|
3
3
|
async isDateTimeChanged() {
|
|
4
4
|
throw this.unimplemented('Not implemented on web.');
|
|
5
5
|
}
|
|
6
|
+
async isDateTimeChangedSimple() {
|
|
7
|
+
throw this.unimplemented('Not implemented on web.');
|
|
8
|
+
}
|
|
6
9
|
// Date/Time Change Detection
|
|
7
10
|
async detectDateTimeChange() {
|
|
8
11
|
throw this.unimplemented('Not implemented on web.');
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -10,6 +10,9 @@ class DateTimeSettingWeb extends core.WebPlugin {
|
|
|
10
10
|
async isDateTimeChanged() {
|
|
11
11
|
throw this.unimplemented('Not implemented on web.');
|
|
12
12
|
}
|
|
13
|
+
async isDateTimeChangedSimple() {
|
|
14
|
+
throw this.unimplemented('Not implemented on web.');
|
|
15
|
+
}
|
|
13
16
|
// Date/Time Change Detection
|
|
14
17
|
async detectDateTimeChange() {
|
|
15
18
|
throw this.unimplemented('Not implemented on web.');
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst DateTimeSetting = registerPlugin('DateTimeSetting', {\n web: () => import('./web').then(m => new m.DateTimeSettingWeb()),\n});\nexport * from './definitions';\nexport { DateTimeSetting };\n","import { WebPlugin } from '@capacitor/core';\nexport class DateTimeSettingWeb extends WebPlugin {\n async isDateTimeChanged() {\n throw this.unimplemented('Not implemented on web.');\n }\n // Date/Time Change Detection\n async detectDateTimeChange() {\n throw this.unimplemented('Not implemented on web.');\n }\n async detectComprehensiveDateTimeChange() {\n throw this.unimplemented('Not implemented on web.');\n }\n async detectDateOnlyChange() {\n throw this.unimplemented('Not implemented on web.');\n }\n async detectAndNotifyDateTimeChanges() {\n throw this.unimplemented('Not implemented on web.');\n }\n // Time Utilities\n async getLocalTime() {\n throw this.unimplemented('Not implemented on web.');\n }\n async getInternetUTCTime() {\n throw this.unimplemented('Not implemented on web.');\n }\n async convertToLocalTime(options) {\n throw this.unimplemented('Not implemented on web.');\n }\n // Timestamp Management\n async setStoredTimestamp(options) {\n throw this.unimplemented('Not implemented on web.');\n }\n async getStoredTimestamp() {\n throw this.unimplemented('Not implemented on web.');\n }\n async resetDetector() {\n throw this.unimplemented('Not implemented on web.');\n }\n}\n"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,eAAe,GAAGA,mBAAc,CAAC,iBAAiB,EAAE;AAC1D,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,kBAAkB,EAAE,CAAC;AACpE,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;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst DateTimeSetting = registerPlugin('DateTimeSetting', {\n web: () => import('./web').then(m => new m.DateTimeSettingWeb()),\n});\nexport * from './definitions';\nexport { DateTimeSetting };\n","import { WebPlugin } from '@capacitor/core';\nexport class DateTimeSettingWeb extends WebPlugin {\n async isDateTimeChanged() {\n throw this.unimplemented('Not implemented on web.');\n }\n async isDateTimeChangedSimple() {\n throw this.unimplemented('Not implemented on web.');\n }\n // Date/Time Change Detection\n async detectDateTimeChange() {\n throw this.unimplemented('Not implemented on web.');\n }\n async detectComprehensiveDateTimeChange() {\n throw this.unimplemented('Not implemented on web.');\n }\n async detectDateOnlyChange() {\n throw this.unimplemented('Not implemented on web.');\n }\n async detectAndNotifyDateTimeChanges() {\n throw this.unimplemented('Not implemented on web.');\n }\n // Time Utilities\n async getLocalTime() {\n throw this.unimplemented('Not implemented on web.');\n }\n async getInternetUTCTime() {\n throw this.unimplemented('Not implemented on web.');\n }\n async convertToLocalTime(options) {\n throw this.unimplemented('Not implemented on web.');\n }\n // Timestamp Management\n async setStoredTimestamp(options) {\n throw this.unimplemented('Not implemented on web.');\n }\n async getStoredTimestamp() {\n throw this.unimplemented('Not implemented on web.');\n }\n async resetDetector() {\n throw this.unimplemented('Not implemented on web.');\n }\n}\n"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,eAAe,GAAGA,mBAAc,CAAC,iBAAiB,EAAE;AAC1D,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,kBAAkB,EAAE,CAAC;AACpE,CAAC;;ACFM,MAAM,kBAAkB,SAASC,cAAS,CAAC;AAClD,IAAI,MAAM,iBAAiB,GAAG;AAC9B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D,IAAI;AACJ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9 @@ var capacitorDatetimeSetting = (function (exports, core) {
|
|
|
9
9
|
async isDateTimeChanged() {
|
|
10
10
|
throw this.unimplemented('Not implemented on web.');
|
|
11
11
|
}
|
|
12
|
+
async isDateTimeChangedSimple() {
|
|
13
|
+
throw this.unimplemented('Not implemented on web.');
|
|
14
|
+
}
|
|
12
15
|
// Date/Time Change Detection
|
|
13
16
|
async detectDateTimeChange() {
|
|
14
17
|
throw this.unimplemented('Not implemented on web.');
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst DateTimeSetting = registerPlugin('DateTimeSetting', {\n web: () => import('./web').then(m => new m.DateTimeSettingWeb()),\n});\nexport * from './definitions';\nexport { DateTimeSetting };\n","import { WebPlugin } from '@capacitor/core';\nexport class DateTimeSettingWeb extends WebPlugin {\n async isDateTimeChanged() {\n throw this.unimplemented('Not implemented on web.');\n }\n // Date/Time Change Detection\n async detectDateTimeChange() {\n throw this.unimplemented('Not implemented on web.');\n }\n async detectComprehensiveDateTimeChange() {\n throw this.unimplemented('Not implemented on web.');\n }\n async detectDateOnlyChange() {\n throw this.unimplemented('Not implemented on web.');\n }\n async detectAndNotifyDateTimeChanges() {\n throw this.unimplemented('Not implemented on web.');\n }\n // Time Utilities\n async getLocalTime() {\n throw this.unimplemented('Not implemented on web.');\n }\n async getInternetUTCTime() {\n throw this.unimplemented('Not implemented on web.');\n }\n async convertToLocalTime(options) {\n throw this.unimplemented('Not implemented on web.');\n }\n // Timestamp Management\n async setStoredTimestamp(options) {\n throw this.unimplemented('Not implemented on web.');\n }\n async getStoredTimestamp() {\n throw this.unimplemented('Not implemented on web.');\n }\n async resetDetector() {\n throw this.unimplemented('Not implemented on web.');\n }\n}\n"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,eAAe,GAAGA,mBAAc,CAAC,iBAAiB,EAAE;IA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;IACJ,IAAI,MAAM,aAAa,GAAG;IAC1B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst DateTimeSetting = registerPlugin('DateTimeSetting', {\n web: () => import('./web').then(m => new m.DateTimeSettingWeb()),\n});\nexport * from './definitions';\nexport { DateTimeSetting };\n","import { WebPlugin } from '@capacitor/core';\nexport class DateTimeSettingWeb extends WebPlugin {\n async isDateTimeChanged() {\n throw this.unimplemented('Not implemented on web.');\n }\n async isDateTimeChangedSimple() {\n throw this.unimplemented('Not implemented on web.');\n }\n // Date/Time Change Detection\n async detectDateTimeChange() {\n throw this.unimplemented('Not implemented on web.');\n }\n async detectComprehensiveDateTimeChange() {\n throw this.unimplemented('Not implemented on web.');\n }\n async detectDateOnlyChange() {\n throw this.unimplemented('Not implemented on web.');\n }\n async detectAndNotifyDateTimeChanges() {\n throw this.unimplemented('Not implemented on web.');\n }\n // Time Utilities\n async getLocalTime() {\n throw this.unimplemented('Not implemented on web.');\n }\n async getInternetUTCTime() {\n throw this.unimplemented('Not implemented on web.');\n }\n async convertToLocalTime(options) {\n throw this.unimplemented('Not implemented on web.');\n }\n // Timestamp Management\n async setStoredTimestamp(options) {\n throw this.unimplemented('Not implemented on web.');\n }\n async getStoredTimestamp() {\n throw this.unimplemented('Not implemented on web.');\n }\n async resetDetector() {\n throw this.unimplemented('Not implemented on web.');\n }\n}\n"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,eAAe,GAAGA,mBAAc,CAAC,iBAAiB,EAAE;IAC1D,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,kBAAkB,EAAE,CAAC;IACpE,CAAC;;ICFM,MAAM,kBAAkB,SAASC,cAAS,CA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M,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ;;;;;;;;;;;;;;;"}
|
|
@@ -391,6 +391,72 @@ class AutoDateTimeDetector {
|
|
|
391
391
|
private static var lastStatusCheckTime: Date?
|
|
392
392
|
private static let statusCacheInterval: TimeInterval = 30.0 // Cache for 30 seconds
|
|
393
393
|
|
|
394
|
+
/**
|
|
395
|
+
* Simple NTP-based check if automatic date/time is enabled (matches Flutter plugin behavior)
|
|
396
|
+
*
|
|
397
|
+
* This method provides a simplified detection approach without caching or complex fallback logic.
|
|
398
|
+
* It directly compares device time with NTP server time using a 30-second threshold.
|
|
399
|
+
*
|
|
400
|
+
* Platform behavior:
|
|
401
|
+
* - Fetches device time (UTC)
|
|
402
|
+
* - Fetches NTP time from worldtimeapi.org
|
|
403
|
+
* - Compares time difference
|
|
404
|
+
* - Returns true if difference ≤ 30 seconds (auto time ON)
|
|
405
|
+
* - Returns false if difference > 30 seconds or network fails (auto time OFF)
|
|
406
|
+
*
|
|
407
|
+
* @param completion Callback with detection result
|
|
408
|
+
*/
|
|
409
|
+
static func isAutoDateTimeEnabledSimple(completion: @escaping (Bool) -> Void) {
|
|
410
|
+
// Get device time in UTC
|
|
411
|
+
let deviceTimeUtc = Date()
|
|
412
|
+
|
|
413
|
+
// Create URL request to NTP time server
|
|
414
|
+
guard let url = URL(string: "https://worldtimeapi.org/api/timezone/Etc/UTC") else {
|
|
415
|
+
// Conservative approach: return false if URL creation fails
|
|
416
|
+
completion(false)
|
|
417
|
+
return
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
var request = URLRequest(url: url)
|
|
421
|
+
request.timeoutInterval = 5.0 // 5 second timeout
|
|
422
|
+
request.cachePolicy = .reloadIgnoringLocalAndRemoteCacheData
|
|
423
|
+
request.setValue("application/json", forHTTPHeaderField: "Accept")
|
|
424
|
+
|
|
425
|
+
let task = URLSession.shared.dataTask(with: request) { data, response, error in
|
|
426
|
+
// Check for network errors
|
|
427
|
+
if let error = error {
|
|
428
|
+
print("Simple NTP check - Network error: \(error.localizedDescription)")
|
|
429
|
+
// Conservative approach: return false on network failure (matching Flutter)
|
|
430
|
+
completion(false)
|
|
431
|
+
return
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
// Parse response data
|
|
435
|
+
guard let data = data,
|
|
436
|
+
let json = try? JSONSerialization.jsonObject(with: data) as? [String: Any],
|
|
437
|
+
let unixTimeString = json["unixtime"] as? Double else {
|
|
438
|
+
print("Simple NTP check - Failed to parse server response")
|
|
439
|
+
// Conservative approach: return false on parse failure
|
|
440
|
+
completion(false)
|
|
441
|
+
return
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
// Get NTP time
|
|
445
|
+
let ntpTimeUtc = Date(timeIntervalSince1970: unixTimeString)
|
|
446
|
+
|
|
447
|
+
// Calculate time difference in seconds
|
|
448
|
+
let timeDifferenceSeconds = abs(deviceTimeUtc.timeIntervalSince(ntpTimeUtc))
|
|
449
|
+
|
|
450
|
+
// Simple threshold check: 30 seconds (matching Flutter plugin)
|
|
451
|
+
let isAutoEnabled = timeDifferenceSeconds <= 30.0
|
|
452
|
+
|
|
453
|
+
print("Simple NTP check - Time difference: \(timeDifferenceSeconds)s, Auto enabled: \(isAutoEnabled)")
|
|
454
|
+
completion(isAutoEnabled)
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
task.resume()
|
|
458
|
+
}
|
|
459
|
+
|
|
394
460
|
/**
|
|
395
461
|
* Checks if automatic date/time is enabled on iOS device (async version)
|
|
396
462
|
* Uses caching to provide instant results and avoid network delays
|
|
@@ -27,9 +27,13 @@ public class DateTimeSettingPlugin: CAPPlugin {
|
|
|
27
27
|
/**
|
|
28
28
|
* Check if date/time has been manually changed (inverse of auto time enabled).
|
|
29
29
|
* This is a simple wrapper that returns !isAutoDateTimeEnabled.
|
|
30
|
+
/**
|
|
31
|
+
* Check if date/time has been manually changed.
|
|
32
|
+
* Returns true if auto date/time is disabled (inverse of auto time enabled).
|
|
30
33
|
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
34
|
+
* This is a simple wrapper from date_change_checker source.
|
|
35
|
+
*
|
|
36
|
+
* @since 2.0.1
|
|
33
37
|
*/
|
|
34
38
|
@objc func isDateTimeChanged(_ call: CAPPluginCall) {
|
|
35
39
|
AutoDateTimeDetector.isAutoDateTimeEnabled { isEnabled in
|
|
@@ -42,6 +46,27 @@ public class DateTimeSettingPlugin: CAPPlugin {
|
|
|
42
46
|
}
|
|
43
47
|
}
|
|
44
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Simple NTP-based check if date/time has been manually changed.
|
|
51
|
+
* Uses basic 30-second threshold comparison without caching.
|
|
52
|
+
*
|
|
53
|
+
* This method matches Flutter plugin behavior exactly:
|
|
54
|
+
* - iOS: Compares device time with NTP server (30s threshold)
|
|
55
|
+
* - Returns true if auto time is disabled or network fails
|
|
56
|
+
*
|
|
57
|
+
* @since 2.1.0
|
|
58
|
+
*/
|
|
59
|
+
@objc func isDateTimeChangedSimple(_ call: CAPPluginCall) {
|
|
60
|
+
AutoDateTimeDetector.isAutoDateTimeEnabledSimple { isEnabled in
|
|
61
|
+
DispatchQueue.main.async {
|
|
62
|
+
// Return !isEnabled to indicate if date/time has been changed
|
|
63
|
+
call.resolve([
|
|
64
|
+
"changed": !isEnabled
|
|
65
|
+
])
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
45
70
|
// MARK: - Date/Time Change Detection
|
|
46
71
|
|
|
47
72
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@greatdayhr/capacitor-datetime-setting",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Capacitor plugin for comprehensive iOS date/time change detection. Cloned from date_change_checker Flutter plugin.",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|