Firebase notifications - subscribing to topics using iOS FCM token failing all the time… using C# API











up vote
0
down vote

favorite












I have an App - Android and iOS with a partial web view.



I'm using a C# API back end and notifications via Firebase Cloud messaging works fine for Android, especially subscribing and unsubscribing to topics using the "registered" FM token.



Every time I try to subscribe to a topic using a FCM token that comes from an iOS device it fails.



I'm using very simple code to add tokens to topics e.g.



using (var httpRequest = new HttpRequestMessage(HttpMethod.Post, "https://iid.googleapis.com/iid/v1/" + [fcmToken] + "/rel/topics/" + [topic name]))
{



httpRequest.Headers.TryAddWithoutValidation("Authorization", [server key]);
httpRequest.Headers.TryAddWithoutValidation("Sender", [sender id]);
httpRequest.Content = new StringContent(jsonBody, Encoding.UTF8, "application/json");

using (var httpClient = new HttpClient())
{
var result = await httpClient.SendAsync(httpRequest);
if (result.IsSuccessStatusCode)
{
//success
}
else
{
//failed
}
}


}



Has anyone had any experience like this or a solution that I'm missing as to why iOS tokens are not getting subscribed to topics?










share|improve this question




























    up vote
    0
    down vote

    favorite












    I have an App - Android and iOS with a partial web view.



    I'm using a C# API back end and notifications via Firebase Cloud messaging works fine for Android, especially subscribing and unsubscribing to topics using the "registered" FM token.



    Every time I try to subscribe to a topic using a FCM token that comes from an iOS device it fails.



    I'm using very simple code to add tokens to topics e.g.



    using (var httpRequest = new HttpRequestMessage(HttpMethod.Post, "https://iid.googleapis.com/iid/v1/" + [fcmToken] + "/rel/topics/" + [topic name]))
    {



    httpRequest.Headers.TryAddWithoutValidation("Authorization", [server key]);
    httpRequest.Headers.TryAddWithoutValidation("Sender", [sender id]);
    httpRequest.Content = new StringContent(jsonBody, Encoding.UTF8, "application/json");

    using (var httpClient = new HttpClient())
    {
    var result = await httpClient.SendAsync(httpRequest);
    if (result.IsSuccessStatusCode)
    {
    //success
    }
    else
    {
    //failed
    }
    }


    }



    Has anyone had any experience like this or a solution that I'm missing as to why iOS tokens are not getting subscribed to topics?










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I have an App - Android and iOS with a partial web view.



      I'm using a C# API back end and notifications via Firebase Cloud messaging works fine for Android, especially subscribing and unsubscribing to topics using the "registered" FM token.



      Every time I try to subscribe to a topic using a FCM token that comes from an iOS device it fails.



      I'm using very simple code to add tokens to topics e.g.



      using (var httpRequest = new HttpRequestMessage(HttpMethod.Post, "https://iid.googleapis.com/iid/v1/" + [fcmToken] + "/rel/topics/" + [topic name]))
      {



      httpRequest.Headers.TryAddWithoutValidation("Authorization", [server key]);
      httpRequest.Headers.TryAddWithoutValidation("Sender", [sender id]);
      httpRequest.Content = new StringContent(jsonBody, Encoding.UTF8, "application/json");

      using (var httpClient = new HttpClient())
      {
      var result = await httpClient.SendAsync(httpRequest);
      if (result.IsSuccessStatusCode)
      {
      //success
      }
      else
      {
      //failed
      }
      }


      }



      Has anyone had any experience like this or a solution that I'm missing as to why iOS tokens are not getting subscribed to topics?










      share|improve this question















      I have an App - Android and iOS with a partial web view.



      I'm using a C# API back end and notifications via Firebase Cloud messaging works fine for Android, especially subscribing and unsubscribing to topics using the "registered" FM token.



      Every time I try to subscribe to a topic using a FCM token that comes from an iOS device it fails.



      I'm using very simple code to add tokens to topics e.g.



      using (var httpRequest = new HttpRequestMessage(HttpMethod.Post, "https://iid.googleapis.com/iid/v1/" + [fcmToken] + "/rel/topics/" + [topic name]))
      {



      httpRequest.Headers.TryAddWithoutValidation("Authorization", [server key]);
      httpRequest.Headers.TryAddWithoutValidation("Sender", [sender id]);
      httpRequest.Content = new StringContent(jsonBody, Encoding.UTF8, "application/json");

      using (var httpClient = new HttpClient())
      {
      var result = await httpClient.SendAsync(httpRequest);
      if (result.IsSuccessStatusCode)
      {
      //success
      }
      else
      {
      //failed
      }
      }


      }



      Has anyone had any experience like this or a solution that I'm missing as to why iOS tokens are not getting subscribed to topics?







      c# android ios firebase firebase-cloud-messaging






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 7 at 12:47









      KENdi

      5,6492821




      5,6492821










      asked Nov 7 at 11:54









      Paul Deehan

      2413




      2413
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          Seeing as your code works fine for Android, but not for iOS I would follow the differences you need to pay attention to:




          • Did you initialize Firebase correctly for iOS? You might need to manually map your APN token to the Firebase token (https://firebase.google.com/docs/cloud-messaging/ios/client)

          • Did you upload the APN certificate to Firebase? (https://firebase.google.com/docs/cloud-messaging/ios/certs)

          • Do you correctly use the Notification Center if you want to display notifications?






          share|improve this answer





















          • Suggested checks have been investigated - presumed to be configured correct. Sadly still getting false trying to add to topics using iOS tokens. Only difference I see is how the token looks between iOS and Android. Working Android token: (dIXd6ZHVyy4:APA91bEO_Xkn9pw8L8gKPRnFDZmVmN5ywyWCrS84uNo8-JwJWq167RjYT4lvhr91DTlEcAbX1k9x4ZsuZvIENBt0evax2RkPhlRdqJUYFtqczl1FuOgCPZIcp13KSFljLseFBZWqIpcB). iOS token (not working): (73FF6FC7BE399395209088B2652468C4E251DD3CDED250342FD1DA2906BF5876). Has anyone else got any suggestions or had a similar issue they managed to resolve? Thanks.
            – Paul Deehan
            Nov 15 at 9:17












          • Sorry I couldn't help, whenever I implemented Firebase notifications, I used native code, which worked when following the instructions... :/
            – Gleydar
            Nov 16 at 10:07













          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53188958%2ffirebase-notifications-subscribing-to-topics-using-ios-fcm-token-failing-all-t%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          Seeing as your code works fine for Android, but not for iOS I would follow the differences you need to pay attention to:




          • Did you initialize Firebase correctly for iOS? You might need to manually map your APN token to the Firebase token (https://firebase.google.com/docs/cloud-messaging/ios/client)

          • Did you upload the APN certificate to Firebase? (https://firebase.google.com/docs/cloud-messaging/ios/certs)

          • Do you correctly use the Notification Center if you want to display notifications?






          share|improve this answer





















          • Suggested checks have been investigated - presumed to be configured correct. Sadly still getting false trying to add to topics using iOS tokens. Only difference I see is how the token looks between iOS and Android. Working Android token: (dIXd6ZHVyy4:APA91bEO_Xkn9pw8L8gKPRnFDZmVmN5ywyWCrS84uNo8-JwJWq167RjYT4lvhr91DTlEcAbX1k9x4ZsuZvIENBt0evax2RkPhlRdqJUYFtqczl1FuOgCPZIcp13KSFljLseFBZWqIpcB). iOS token (not working): (73FF6FC7BE399395209088B2652468C4E251DD3CDED250342FD1DA2906BF5876). Has anyone else got any suggestions or had a similar issue they managed to resolve? Thanks.
            – Paul Deehan
            Nov 15 at 9:17












          • Sorry I couldn't help, whenever I implemented Firebase notifications, I used native code, which worked when following the instructions... :/
            – Gleydar
            Nov 16 at 10:07

















          up vote
          0
          down vote













          Seeing as your code works fine for Android, but not for iOS I would follow the differences you need to pay attention to:




          • Did you initialize Firebase correctly for iOS? You might need to manually map your APN token to the Firebase token (https://firebase.google.com/docs/cloud-messaging/ios/client)

          • Did you upload the APN certificate to Firebase? (https://firebase.google.com/docs/cloud-messaging/ios/certs)

          • Do you correctly use the Notification Center if you want to display notifications?






          share|improve this answer





















          • Suggested checks have been investigated - presumed to be configured correct. Sadly still getting false trying to add to topics using iOS tokens. Only difference I see is how the token looks between iOS and Android. Working Android token: (dIXd6ZHVyy4:APA91bEO_Xkn9pw8L8gKPRnFDZmVmN5ywyWCrS84uNo8-JwJWq167RjYT4lvhr91DTlEcAbX1k9x4ZsuZvIENBt0evax2RkPhlRdqJUYFtqczl1FuOgCPZIcp13KSFljLseFBZWqIpcB). iOS token (not working): (73FF6FC7BE399395209088B2652468C4E251DD3CDED250342FD1DA2906BF5876). Has anyone else got any suggestions or had a similar issue they managed to resolve? Thanks.
            – Paul Deehan
            Nov 15 at 9:17












          • Sorry I couldn't help, whenever I implemented Firebase notifications, I used native code, which worked when following the instructions... :/
            – Gleydar
            Nov 16 at 10:07















          up vote
          0
          down vote










          up vote
          0
          down vote









          Seeing as your code works fine for Android, but not for iOS I would follow the differences you need to pay attention to:




          • Did you initialize Firebase correctly for iOS? You might need to manually map your APN token to the Firebase token (https://firebase.google.com/docs/cloud-messaging/ios/client)

          • Did you upload the APN certificate to Firebase? (https://firebase.google.com/docs/cloud-messaging/ios/certs)

          • Do you correctly use the Notification Center if you want to display notifications?






          share|improve this answer












          Seeing as your code works fine for Android, but not for iOS I would follow the differences you need to pay attention to:




          • Did you initialize Firebase correctly for iOS? You might need to manually map your APN token to the Firebase token (https://firebase.google.com/docs/cloud-messaging/ios/client)

          • Did you upload the APN certificate to Firebase? (https://firebase.google.com/docs/cloud-messaging/ios/certs)

          • Do you correctly use the Notification Center if you want to display notifications?







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 7 at 12:22









          Gleydar

          84




          84












          • Suggested checks have been investigated - presumed to be configured correct. Sadly still getting false trying to add to topics using iOS tokens. Only difference I see is how the token looks between iOS and Android. Working Android token: (dIXd6ZHVyy4:APA91bEO_Xkn9pw8L8gKPRnFDZmVmN5ywyWCrS84uNo8-JwJWq167RjYT4lvhr91DTlEcAbX1k9x4ZsuZvIENBt0evax2RkPhlRdqJUYFtqczl1FuOgCPZIcp13KSFljLseFBZWqIpcB). iOS token (not working): (73FF6FC7BE399395209088B2652468C4E251DD3CDED250342FD1DA2906BF5876). Has anyone else got any suggestions or had a similar issue they managed to resolve? Thanks.
            – Paul Deehan
            Nov 15 at 9:17












          • Sorry I couldn't help, whenever I implemented Firebase notifications, I used native code, which worked when following the instructions... :/
            – Gleydar
            Nov 16 at 10:07




















          • Suggested checks have been investigated - presumed to be configured correct. Sadly still getting false trying to add to topics using iOS tokens. Only difference I see is how the token looks between iOS and Android. Working Android token: (dIXd6ZHVyy4:APA91bEO_Xkn9pw8L8gKPRnFDZmVmN5ywyWCrS84uNo8-JwJWq167RjYT4lvhr91DTlEcAbX1k9x4ZsuZvIENBt0evax2RkPhlRdqJUYFtqczl1FuOgCPZIcp13KSFljLseFBZWqIpcB). iOS token (not working): (73FF6FC7BE399395209088B2652468C4E251DD3CDED250342FD1DA2906BF5876). Has anyone else got any suggestions or had a similar issue they managed to resolve? Thanks.
            – Paul Deehan
            Nov 15 at 9:17












          • Sorry I couldn't help, whenever I implemented Firebase notifications, I used native code, which worked when following the instructions... :/
            – Gleydar
            Nov 16 at 10:07


















          Suggested checks have been investigated - presumed to be configured correct. Sadly still getting false trying to add to topics using iOS tokens. Only difference I see is how the token looks between iOS and Android. Working Android token: (dIXd6ZHVyy4:APA91bEO_Xkn9pw8L8gKPRnFDZmVmN5ywyWCrS84uNo8-JwJWq167RjYT4lvhr91DTlEcAbX1k9x4ZsuZvIENBt0evax2RkPhlRdqJUYFtqczl1FuOgCPZIcp13KSFljLseFBZWqIpcB). iOS token (not working): (73FF6FC7BE399395209088B2652468C4E251DD3CDED250342FD1DA2906BF5876). Has anyone else got any suggestions or had a similar issue they managed to resolve? Thanks.
          – Paul Deehan
          Nov 15 at 9:17






          Suggested checks have been investigated - presumed to be configured correct. Sadly still getting false trying to add to topics using iOS tokens. Only difference I see is how the token looks between iOS and Android. Working Android token: (dIXd6ZHVyy4:APA91bEO_Xkn9pw8L8gKPRnFDZmVmN5ywyWCrS84uNo8-JwJWq167RjYT4lvhr91DTlEcAbX1k9x4ZsuZvIENBt0evax2RkPhlRdqJUYFtqczl1FuOgCPZIcp13KSFljLseFBZWqIpcB). iOS token (not working): (73FF6FC7BE399395209088B2652468C4E251DD3CDED250342FD1DA2906BF5876). Has anyone else got any suggestions or had a similar issue they managed to resolve? Thanks.
          – Paul Deehan
          Nov 15 at 9:17














          Sorry I couldn't help, whenever I implemented Firebase notifications, I used native code, which worked when following the instructions... :/
          – Gleydar
          Nov 16 at 10:07






          Sorry I couldn't help, whenever I implemented Firebase notifications, I used native code, which worked when following the instructions... :/
          – Gleydar
          Nov 16 at 10:07




















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53188958%2ffirebase-notifications-subscribing-to-topics-using-ios-fcm-token-failing-all-t%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          Xamarin.form Move up view when keyboard appear

          Post-Redirect-Get with Spring WebFlux and Thymeleaf

          Anylogic : not able to use stopDelay()