Re-submitting this question because we've made quite a bit of progress, but not quite sorted yet. Been using this library and functions successfully since 2021 in my Android App
com.microsoft.azure:notification-hubs-android-sdk-fcm:1.1.4
registerTemplate creates GcmTemplateRegistrationDescription and GcmRegistrationId fine
Need to create FcmV1TemplateRegistration and FcmV1RegistrationId so updated to 2.0.0
com.microsoft.azure:notification-hubs-android-sdk:2.0.0
Call to registerTemplate on device now creates FcmV1TemplateRegistration in Azure Hub
(Get Android device regid with FirebaseMessaging.getInstance().getToken() function first)
String messageTemplate = "{\"message\":{\"android\":{\"data\":{\"msgtext\":\"$(msgtext)\",\"msgsndr\":\"$(msgsndr)\"}}}}";
String RegistrationTagTopic = "5050";
mobile_RegistrationId = hub.registerTemplate(regid, "CAREV1", messageTemplate, RegistrationTagTopic).getRegistrationId();
Example registration: mobile_RegistrationId returned above is Notification Hub RegistrationId
<ETag>5</ETag>
<ExpirationTime>2124-06-12T05:55:24.1941413Z</ExpirationTime>
<RegistrationId>2837404...516-2</RegistrationId>
<Tags>5050</Tags>
<FcmV1RegistrationId>eZMPxd2pQBi...Uh</FcmV1RegistrationId>
<BodyTemplate><![CDATA[{"message":{"android":{"data":{"msgtext":"$(msgtext)","msgsndr":"$(msgsndr)"}}}}]]></BodyTemplate>
<TemplateName>CAREV1</TemplateName>
</FcmV1TemplateRegistrationDescription>
It seems the format of the template in the App for FCMv1 is absolutely critical because my App threw an exception on register with any other format than {"message":{"android":{"data":{...}}}}
Send to device tag 5050 using Azure Notification Hubs REST API Method, same API call we've used successfully since 2015 (presume you know how to generate your Authorization token): Send a template notification with parameters like;
ServiceBusNotification-Format = "template"
ServiceBusNotification-Tags = "5050"
ContentType = "application/json;charset=utf-8."
Method = "POST"
URI = "https://{namespace}.servicebus.windows.net/{NotificationHub}/messages/?api-version=2015-01"
Example of JSON posted in the call
{"message":{"android":{"data":{"msgtext":"My short message","msgsndr":"ADMIN"}}}}
Notification is received on the device fine, but there is no payload
Logged using &test mode with REST API, everything looks like it worked, Reg Id and PnsHandle both match and recognizes fcmV1Template
address : 5050
Success : 1
Failure : 0
Appform : fcmV1Template
Reg Id : 2837404...516-2
PnsHandle : eZMPxd2pQBi...Uh
Outcome : The Notification was successfully sent to the Push Notification System
Send (POST) same message direct to 5050 via FCM/JWT routine, slightly different JSON format;
{"message":{"topic":"5050","data":{"msgtext":"My short message","msgsndr":"ADMIN"},"android":{"priority":"high"},"fcm_options":{"analytics_label":"xyz"}}}
Notification and message payload are perfect (note extra FCM parameters) and works every time. Of course, FCM doesn't require a template in the App itself or the server process.
Question: What's going wrong with my template send via Notification Hubs..?