You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/offline-device-handling.md
+9-11Lines changed: 9 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,6 @@
1
1
# Handling notifications while a device is offline or airplane mode
2
2
3
-
### The problem
4
-
5
-
Currently, Notifo supports only firebase [notification](https://firebase.google.com/docs/cloud-messaging/concept-options#notifications_and_data_messages) messages that are [always collapsible](https://firebase.google.com/docs/cloud-messaging/concept-options#collapsible_and_non-collapsible_messages) and if we send multiple notifications to a device while it is offline, only the most recent notification will show when the device comes back online.
6
-
7
-
### Possible solution
8
-
9
-
For Android the solution is pretty easy, we just need to extend Notifo to be able to send firebase [data](https://firebase.google.com/docs/cloud-messaging/concept-options#notifications_and_data_messages) messages, which are non-collapsible by default and have a [default time-to-live period](https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages/#androidconfig) of four weeks (probably we need to reduce this), so we can receive all offline messages. But for iOS Apple will only store the most recent notification sent to a device on the [APNs servers](https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/APNSOverview.html#//apple_ref/doc/uid/TP40008194-CH8-SW5). So turns out for iOS we need a completely different custom solution.
3
+
For Android the solution is pretty easy, Notifo is able to send firebase [data](https://firebase.google.com/docs/cloud-messaging/concept-options#notifications_and_data_messages) messages, which are non-collapsible by default and have a [default time-to-live period](https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages/#androidconfig) of four weeks, so we can receive all offline messages. But for iOS Apple will only store the most recent notification sent to a device on the [APNs servers](https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/APNSOverview.html#//apple_ref/doc/uid/TP40008194-CH8-SW5). So turns out for iOS we need a completely different custom solution.
10
4
11
5
First, we need to send different types of messages for Android and iOS. Android will need data messages and iOS will need notification messages. It is because iOS will treat data messages as [silent](https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/pushing_background_updates_to_your_app) messages and Apple [does not guarantee](https://firebase.google.com/docs/cloud-messaging/ios/receive#handle_silent_push_notifications) the delivery of silent messages and put other restrictions on them.
12
6
@@ -30,16 +24,20 @@ In order to send platform-specific message payload, we need to use [Firebase HTT
30
24
"body": "Body iOS"
31
25
},
32
26
"mutable-content": 1
33
-
},
34
-
"notification-id": "unique-id"
27
+
}
35
28
}
36
29
}
37
30
}
38
31
}
39
32
```
40
33
41
-
Second, when the last notification gets delivered after the device will back online we will send a delivery report to Notifo backend of that notification with a unique notification ID, then the backend will check for all the notifications that were not delivered and will send them again (that should be done only for iOS devices, so seems that we need to somehow distinguish between platforms, maybe send platform name together with device token).
34
+
Second, when the last notification gets delivered after the device will back online we will send a delivery report to Notifo backend using a unique `trackingUrl`, then the Notifo backend will schedule a background/silent notification to wakeup the iOS device (no more than once per 30 minutes). This background notification will initiate fetch and show pending offline notifications as local notifications on the iOS device.
35
+
36
+
### Notification Service Extension
37
+
Apple doesn’t provide any official method to know when a Push Notification has been delivered to the user’s device. We are using [UNNotificationServiceExtension](https://developer.apple.com/documentation/usernotifications/unnotificationserviceextension) for that purposes. It turns out to be a viable solution, the only limitation is we have 30 seconds to send the delivery report to Notifo backend, but that feels more than enough. For this solution, there is included `mutable-content` parameter in the payload example above.
42
38
43
-
Unfortunately, Apple doesn’t provide any official method to know when a Push Notification has delivered to the user’s device. But seems like [UNNotificationServiceExtension](https://developer.apple.com/documentation/usernotifications/unnotificationserviceextension) is a viable solution, the only limitation is we have 30 seconds to send the delivery report to Notifo backend, but that feels more than enough. For this solution, there are included “mutable-content” and “notification-id” parameters in the payload example above.
39
+
### App groups
40
+
For tracking/storing delivered notifications locally we are using `Xamarin.Essentials.Preferences` (that uses iOS `UserDefaults` on the iOS platform). In order to be able to share data between a host app and its app extension, we need to configure an [app group capability](https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_security_application-groups).
41
+
Name convetion for app group is `group.{app-bundle-id}.notifo`.
Copy file name to clipboardExpand all lines: docs/release-nuget.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,9 +13,9 @@ We use [Github Actions](https://docs.github.com/en/actions) to release NuGet pac
13
13
* v1.0.0
14
14
* v0.0.1-alpha1
15
15
*(Note: suffix **-alpha**, **-beta** will publish [pre-release](https://docs.microsoft.com/en-us/nuget/concepts/package-versioning#pre-release-versions) version of NuGet package.)*
* To notify users that the release is not ready for production and may be unstable, select **This is a pre-release**.
20
20

21
21
* Click **Publish release**. It will trigger the workflow in [publish.yml](https://github.com/notifo-io/sdk-xamarin/blob/master/.github/workflows/publish.yml) and after a few minutes, the new release should be available in [nuget.org](https://www.nuget.org/packages?q=Notifo).
0 commit comments