Firebase Admin SDK .net Core send Backgrouund Message to iOS App

Viewed 716

I'm trying to send background notification to my app with the Firebase Admin SDK for C# .Net Core. I'm able to do this using apple APN https endpoints (So I know the app is setup to handle this).

When I run the below code I'm getting the success message back from Firebase BUT the app is not receiving the message. When I do an Alert notification I see that on the phone as expect, it is just the background notification that seems to get lost.

var fireMessages = new List<FireMessage>()
{
    new FireMessage()
    {
        Data =  new Dictionary<string, string>(){{"type","update"}},
        Token = token,
        Apns = new ApnsConfig
        {
            Headers = new Dictionary<string, string>
            {
                {"apns-id", Guid.NewGuid().ToString("D")},
                {"apns-push-type", "background"},
                {"apns-priority", "10"},
                {"apns-topic", "com.namespace.dev"},
            },
            Aps = new Aps
            {
                ContentAvailable = true
            }
        }
    }
};

var firebaseApp = FirebaseApp.GetInstance(instanceName);

var batchResponse = await FirebaseMessaging.GetMessaging(firebaseApp).SendAllAsync(fireMessages);

if(batchResponse.FailureCount == 0){
    return true;
}
return false;
0 Answers
Related