0

I'm able to send global notifications using Firebase messaging to all devices using the Firebase console. Now I'm trying to target certain devices by using topic subscription.

In my code I'm subscribing to topics that might not exist yet using the code:

FIRMessaging.messaging().subscribe(toTopic: "/topics/topic1")

However, after this line runs I don't see any topics added in the Firebase console:

console

Does anybody know if I'm doing anything wrong? Note the code I'm running is in a random viewController in a part of my app where I want to subscribe the user to a certain topic.

AL.
  • 36,815
  • 10
  • 142
  • 281
MarksCode
  • 8,074
  • 15
  • 64
  • 133

1 Answers1

2

It takes about 1 day for a topic you created to show up in the Firebase Notifications Console (see my answer here).

For the meantime, you can simply use Postman or cURL to send to your topic.

Graham
  • 7,431
  • 18
  • 59
  • 84
AL.
  • 36,815
  • 10
  • 142
  • 281
  • Ok good to know, some topics I created maybe 2-3 hours ago are just starting to show up. I'm using the topic messaging to message users belonging to specific groups in my iPhone app and would've liked for notifications to start being sent out immediately after a user makes a new topic, but I guess starting up to a day later isn't the end of the world. I'll check out your suggestions though. – MarksCode Mar 28 '17 at 02:44
  • If you have your own App Server, you can immediately send towards a topic as soon as it already has a subscriber. It just takes time for it to show up in the console. – AL. Mar 28 '17 at 02:55
  • Well can I just use the Swift line `FIRMessaging.messaging().sendMessage(["title":"Hello","body":"hello"], to: "/topics/topic2", withMessageID: "1", timeToLive: 1000)` immediately as well? – MarksCode Mar 28 '17 at 03:11
  • That's for [Sending an Upstream Message](https://firebase.google.com/docs/cloud-messaging/ios/upstream). You'll have to implement your own [XMPP Server](https://firebase.google.com/docs/cloud-messaging/server#implementing-the-xmpp-connection-server-protocol). – AL. Mar 28 '17 at 03:15
  • Thanks AL., I'm pretty lost as to what would be the simplest way to trigger a topic notification client side as I thought thats what the `FIRMessaging.messaging().sendMessage` was for. Can you please give me any tips as to what I should look into, I don't know much about servers which is why I'm using Firebase for my database, storage etc.. – MarksCode Mar 28 '17 at 03:40
  • It's not really advisable to send notifications from the Client side. Simply use the Firebase Notifications Console when you need it. The limitation you only seem to be encountering is the time it needs to show in the console. In which case just use Postman or cURL while it's not yet visible, like I mentioned in the answer. You just have modify the payload and it's good to go. – AL. Mar 28 '17 at 03:52
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/139197/discussion-between-markscode-and-al). – MarksCode Mar 28 '17 at 03:55