Push notifications come in so many flavours these days. The community needed one way of doing things, but the ability to swap providers in and out at will. The reason, push providers, aside from native have been dropping
like flies the last several years. The latest to go was AppCenter which it turns out the Xamarin community was heavily invested in.
Native push is the root of all other push providers. It works at the native OS level and is usually feeding other providers like Azure Notification Hubs and Firebase. As such, the setup instructions found
within this document generally apply to all.
Setup
General OS setup is mostly the same on all platforms, but please review the specific provider you intend to use from the menu for more information
Nuget
Project File (csproj)
MauiProgram.cs
AndroidManifest.xml
Android Activity
Apple Info.plist
Apple PrivacyInfo.xcprivacy
Apple App Delegate
Shiny.Push
Shiny.Hosting.Maui
Android Setup
Android has two options for configuration.
Option 1 - google-services.json
You can download the google-services.json file from Firebase, you can place it in the Platforms/Android part of your MAUI project.
Next, open your csproj file and add the following:
Options 2 - Configuration Variables
You still need to download the google-services.json, but this time, open it in a text editor
With 1 of these options now in place, follow the base setup instructions above
Registration
Look to each appropriate provider to see setups for each. The most important function otherwise, is RequestAccess shown below which will give you the push notification token that you can send to your backend.
All providers use the native implementations on the platform to some degree, as such, you will always need to call
Background Delegate
Tags
Like other modules in Shiny, there are certain providers that support additional feature sets. Push really only has 1 extra, tagging.
The following providers, support tagging
Azure Notification Hubs
Firebase
Android Firebase (Native)
Android
No matter what mechanism you use in Push (both iOS & Android), the platform always rules push. For Android,
everything is built on Firebase.
To get push entry delegate events to fire, you must add the following
an intent filter as shown below to one (likely your main activity) activities
iOS
iOS is generally pretty straight forward, but does require a few extra steps shown at the top of this page in the library builder.
Customizing iOS Responses
Your push delegate can implement the IApplePushDelegate interface to customize the presentation options and background fetch result. The following is an example of how to do this: