Commit 675f9f7
authored
Add manual push completion handler support for iOS (#4335)
Fixed #3541
* Add manual push completion handler support for iOS
Added Display.notifyPushCompletion() to allow applications to manually signal when they have finished handling a push notification on iOS.
This is useful for apps that need to perform background tasks (like playing audio) before the app is suspended.
This feature is enabled by setting the build hint `ios.delayPushCompletion` to `true`.
* Add manual push completion handler support for iOS
Added Display.notifyPushCompletion() to allow applications to manually signal when they have finished handling a push notification on iOS.
This is useful for apps that need to perform background tasks (like playing audio) before the app is suspended.
This feature is enabled by setting the build hint `ios.delayPushCompletion` to `true`.
* Implement cross-platform push completion handling for background tasks.
Added Display.notifyPushCompletion() to manually signal the completion of a background push task (e.g. playing audio).
On iOS, this delays the call to the system completion handler if the `ios.delayPushCompletion` or `delayPushCompletion` property is set.
On Android, this releases a partial WakeLock acquired when the push is received, preventing the device from sleeping during the task if the `android.delayPushCompletion` or `delayPushCompletion` property is set.
Updated `IOSImplementation`, `AndroidImplementation`, and `PushNotificationService` to support this logic.
* Implement cross-platform push completion handling for background tasks (opt-in).
Added Display.notifyPushCompletion() to manually signal the completion of a background push task.
This mechanism is OPT-IN via the `delayPushCompletion` (or `android.delayPushCompletion`/`ios.delayPushCompletion`) build hint.
If the hint is present and true:
- Android: Acquires a `PARTIAL_WAKE_LOCK` upon receiving a push, preventing the device from sleeping until `notifyPushCompletion()` is called (or timeout).
- iOS: Ensures the `remote-notification` background mode is enabled and delays firing the system completion handler until `notifyPushCompletion()` is called.
If the hint is NOT present (default behavior):
- Android: No wake lock is acquired.
- iOS: The completion handler is fired immediately after the push callback.
Updated `IOSImplementation`, `AndroidImplementation`, `PushNotificationService`, `AndroidGradleBuilder`, and `IPhoneBuilder`.
* Implement cross-platform push completion handling for background tasks (opt-in).
Added Display.notifyPushCompletion() to manually signal the completion of a background push task.
This mechanism is OPT-IN via the `delayPushCompletion` (or `android.delayPushCompletion`/`ios.delayPushCompletion`) build hint.
If the hint is present and true:
- Android: Acquires a `PARTIAL_WAKE_LOCK` upon receiving a push, preventing the device from sleeping until `notifyPushCompletion()` is called (or timeout).
- iOS: Ensures the `remote-notification` background mode is enabled and delays firing the system completion handler until `notifyPushCompletion()` is called.
The builders (`IPhoneBuilder`, `AndroidGradleBuilder`) have been updated to check for this hint and automatically:
1. Inject the permission (Android) or capability (iOS) into the native project configuration.
2. Inject the `delayPushCompletion` property into the runtime environment so the logic in `PushNotificationService` and `IOSImplementation` activates.
Updated the developer guide to document this new feature.
* Fix compilation error in AndroidImplementation.
Corrected the placement of `notifyPushCompletion()` in `AndroidImplementation.java` to resolve the "java.lang.Override is not a repeatable annotation type" error caused by improper nesting with `notifyCommandBehavior`.
This completes the cross-platform push completion support feature, which is OPT-IN via the `delayPushCompletion` build hint.
If the hint is present and true:
- Android: Acquires a `PARTIAL_WAKE_LOCK` upon receiving a push, releasing it only when `notifyPushCompletion()` is called.
- iOS: Delays firing the system completion handler until `notifyPushCompletion()` is called.
Builders have been updated to inject the necessary permissions and runtime properties.
Developer guide documentation has been updated.
---------
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>1 parent c2a1706 commit 675f9f7
File tree
8 files changed
+119
-5
lines changed- CodenameOne/src/com/codename1
- impl
- ui
- Ports
- Android/src/com/codename1/impl/android
- iOSPort/src/com/codename1/impl/ios
- docs/developer-guide
- maven/codenameone-maven-plugin/src/main/java/com/codename1/builders
8 files changed
+119
-5
lines changedLines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1263 | 1263 | | |
1264 | 1264 | | |
1265 | 1265 | | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
1266 | 1272 | | |
1267 | 1273 | | |
1268 | 1274 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5152 | 5152 | | |
5153 | 5153 | | |
5154 | 5154 | | |
| 5155 | + | |
| 5156 | + | |
| 5157 | + | |
| 5158 | + | |
| 5159 | + | |
| 5160 | + | |
| 5161 | + | |
| 5162 | + | |
| 5163 | + | |
| 5164 | + | |
| 5165 | + | |
| 5166 | + | |
| 5167 | + | |
| 5168 | + | |
| 5169 | + | |
| 5170 | + | |
5155 | 5171 | | |
5156 | 5172 | | |
5157 | 5173 | | |
| |||
Lines changed: 27 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
| 56 | + | |
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
| |||
280 | 281 | | |
281 | 282 | | |
282 | 283 | | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
283 | 297 | | |
284 | 298 | | |
285 | 299 | | |
| |||
2783 | 2797 | | |
2784 | 2798 | | |
2785 | 2799 | | |
2786 | | - | |
| 2800 | + | |
| 2801 | + | |
| 2802 | + | |
| 2803 | + | |
| 2804 | + | |
| 2805 | + | |
| 2806 | + | |
| 2807 | + | |
| 2808 | + | |
| 2809 | + | |
| 2810 | + | |
| 2811 | + | |
2787 | 2812 | | |
2788 | 2813 | | |
2789 | 2814 | | |
| |||
Lines changed: 12 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
112 | 117 | | |
113 | 118 | | |
114 | | - | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
115 | 126 | | |
116 | 127 | | |
117 | 128 | | |
| |||
Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8115 | 8115 | | |
8116 | 8116 | | |
8117 | 8117 | | |
8118 | | - | |
| 8118 | + | |
| 8119 | + | |
| 8120 | + | |
| 8121 | + | |
8119 | 8122 | | |
8120 | 8123 | | |
8121 | 8124 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
90 | 128 | | |
91 | 129 | | |
92 | 130 | | |
| |||
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1163 | 1163 | | |
1164 | 1164 | | |
1165 | 1165 | | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
1166 | 1170 | | |
1167 | 1171 | | |
1168 | 1172 | | |
| |||
3894 | 3898 | | |
3895 | 3899 | | |
3896 | 3900 | | |
| 3901 | + | |
| 3902 | + | |
| 3903 | + | |
| 3904 | + | |
3897 | 3905 | | |
3898 | 3906 | | |
3899 | 3907 | | |
| |||
Lines changed: 8 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
956 | 956 | | |
957 | 957 | | |
958 | 958 | | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
959 | 964 | | |
960 | 965 | | |
| 966 | + | |
961 | 967 | | |
962 | 968 | | |
963 | 969 | | |
| |||
2380 | 2386 | | |
2381 | 2387 | | |
2382 | 2388 | | |
2383 | | - | |
| 2389 | + | |
| 2390 | + | |
2384 | 2391 | | |
2385 | 2392 | | |
2386 | 2393 | | |
| |||
0 commit comments