Ahmet Özdemir

Ahmet Özdemir

  • NA
  • 6
  • 1.9k

Sending notifications to mobile devices using firebase Firebase Admin

Mar 12 2021 11:34 AM
I'm trying to send notifications to mobile devices using firebase admin sdk with asp.net mvc... But I'm stuck a certain request limit. Is there any way to get around this limit? I share some snippets of my code below.
  1. var path = HttpContext.Current.Server.MapPath("~/assd.json");  
  2. var path = HttpContext.Current.Server.MapPath("~/assd.json");    
  3. FirebaseApp.Create(new AppOptions()    
  4. {    
  5.     Credential = GoogleCredential.FromFile(path),    
  6.     ProjectId = "*********",    
  7. });    
  8.   
  9. var message = new MulticastMessage    
  10. {    
  11.     Data = new Dictionary<stringstring>()    
  12.          {    
  13.             { "type", type },    
  14.             { "typeValue", typeValue },    
  15.             { "isSound", isSound.ToString()},    
  16.             { "title", title},    
  17.             { "body", spot },    
  18.   
  19.          },    
  20.     Apns = new ApnsConfig()    
  21.     {    
  22.         Headers = new Dictionary<stringstring>()    
  23.     {    
  24.         { "apns-priority""10" },    
  25.     },    
  26.         Aps = new Aps()    
  27.         {    
  28.             Alert = new ApsAlert()    
  29.             {    
  30.                 Title = title,    
  31.                 Body = spot,    
  32.             },    
  33.             Badge = 1,    
  34.         },    
  35.     },    
  36.     Tokens = tokens,    
  37. };    
  38.   
  39. var response =FirebaseMessaging.DefaultInstance.SendMulticastAsync(message).Result;    
  40. if (response.FailureCount > 0)    
  41. {    
  42.     var failedTokens = new List<string>();    
  43.     for (var i = 0; i < response.Responses.Count; i++)    
  44.     {    
  45.         if (!response.Responses[i].IsSuccess)    
  46.         {    
  47.             failedTokens.Add(tokens[i]);    
  48.             listLog.Add(tokens[i]);    
  49.         }    
  50.     }    
  51. }  
I also try to use the topic system, but it also has a limit.
 
Thank you.. Sofware Developer

Answers (1)