TobiasBuchholz / Plugin.Firebase

Wrapper around the native Android and iOS Firebase Xamarin SDKs
MIT License
220 stars 49 forks source link

iOS app not receiving fcm background notification when using an apple distribution profile #345

Open FranzSY opened 1 month ago

FranzSY commented 1 month ago

Hello,

Our team have been trying to migrate a push notification feature from our old xamarin app. Followed the tutorial on setting up iOS development and development works pretty smooth on windows 11 so far. But upon achiving the iOS app for distribution release, we can't seem to receive a background notification. the app still able to generate a new token though.

The new firebase implementation of our project is mostly from Cedric Gabrang's sample :https://cedricgabrang.medium.com/firebase-push-notifications-in-net-maui-ios-2f4388bf1ac and we are using the latest .Net 8 and here are the related packages that has been added on our project:

        <PackageReference Include="Plugin.Firebase" Version="3.0.0" />
        <PackageReference Include="Plugin.Firebase.CloudMessaging" Version="3.0.0" />
        <PackageReference Include="Plugin.Firebase.Crashlytics" Version="3.0.0" />
                <PackageReference Include="AdamE.Firebase.iOS.Core" Version="10.24.0.2" />

It was specified on the documentation,

"For testing launch the app without the debugger, otherwise the push notification may not be received"

, so we've added this code on our settings. <MtouchDebug>False</MtouchDebug> I feel like we're doing things wrong in this part, so It would be great to know if we're wrong in this part. Thanks!

We've also added a different entitlement on our release settings: Production: <CodesignEntitlements>Platforms\iOS\EntitlementsDevelopment.plist</CodesignEntitlements> Development: <CodesignEntitlements>Platforms\iOS\EntitlementsDevelopment.plist</CodesignEntitlements> The only difference is aps-environment is set as this

    <key>aps-environment</key>
    <string>production</string>

We've tried to set the aps environment of our production entitlement to development, but upon installing the app we are getting an alert "integrity could not be verified"

We've also updated certificates and provisioning profile for both development and distribution 5 times already with no luck on distribution end.

Now on our firebase account, we are currently using a APNs authentication key and blank APNS certificate. - Changing using APNs Key to APNs certificate is the last one we haven't tried yet but this is the existing firebase we have and might affect the production build on our app.

So It would be great to get some fixed and some insights if you guys encountered this issue. Thanks so much!

douglasc211 commented 2 weeks ago

I am there as well, Using Maui for Android and iOS. Android works, iOS does not notify. I notice that both our apps do grab the token successfully. Have you solved this issue? We only direct reference firebase 3.0, it seems that the AdamE ios plugin may come along with that. We reference .Auth , .CloudMessaging and . Core

await CrossFirebaseCloudMessaging.Current.CheckIfValidAsync(); var firebaseToken = await CrossFirebaseCloudMessaging.Current.GetTokenAsync();