iOS Tutorial FirebaseNotifications / Push Messages (server not required)

Status
Not open for further replies.

cloner7801

Active Member
Licensed User
In ios 10 , we can send a media (image) near push and if 3d touch the notifcation that image show.
Is this support send media ?
 

JohnnyHamburg

Member
Licensed User
Why do we have to put "ios_" prefix to the topicname?
I have no problems sending and receiving messages between android and iphone without the "ios_"-prefix.
 

sergiones

Member
Licensed User
I'm unable to receive the push notification. I did all the steps (actually I revoked all certificates and created new ones from scratch), the Sub Application_RemoteNotification is not being called.

fm_FCMConnected works, I'm using fm.SubscribeToTopic("ios_mySubject") and I can see this topic on Firebase console.

I sent a few messages for this topic using firebase, firebase says the message was sent but no activity on RemoteNotification Sub with a message box.

I'm using B4i version 3.01 with iOs 10.0.

Am I missing something?

Thank you.
 

JohnnyHamburg

Member
Licensed User
I sent a few messages for this topic using firebase
I'm a beginner too, but Erel mentioned quite often that we have to use the B4J-app from the first post to send messages. NOT firebase!
I send with my app from iphone or android. You can receive your own messages.
 

sergiones

Member
Licensed User
I'm a beginner too, but Erel mentioned quite often that we have to use the B4J-app from the first post to send messages. NOT firebase!
I send with my app from iphone or android. You can receive your own messages.
You are right, thanks. I don't remember something so unproductive as iOs...
 

JohnnyHamburg

Member
Licensed User
I have to ask again about the difference to use the "ios_" prefix in the topic. Is it just for the notification, that is handled another way than android?
I send only data between the devices and it works without prefix.
 

Erel

Administrator
Staff member
Licensed User
This is the code:
B4X:
Dim Job As HttpJob
   Job.Initialize("fcm", Me)
   Dim m As Map = CreateMap("to": $"/topics/${Topic}"$)
   Dim data As Map = CreateMap("title": Title, "body": Body)
   If Topic.StartsWith("ios_") Then
     Dim iosalert As Map =  CreateMap("title": Title, "body": Body, "sound": "default")
     m.Put("notification", iosalert)
     m.Put("priority", 10)
     'm.Put("content_available", True)
   End If
   m.Put("data", data)
It is required for the notification on iOS.
 

Alpandino

Member
Licensed User
This is the code:
B4X:
Dim Job As HttpJob
   Job.Initialize("fcm", Me)
   Dim m As Map = CreateMap("to": $"/topics/${Topic}"$)
   Dim data As Map = CreateMap("title": Title, "body": Body)
   If Topic.StartsWith("ios_") Then
     Dim iosalert As Map =  CreateMap("title": Title, "body": Body, "sound": "default")
     m.Put("notification", iosalert)
     m.Put("priority", 10)
     'm.Put("content_available", True)
   End If
   m.Put("data", data)
It is required for the notification on iOS.

So, If I send a notification from an Android App I must insert the code
B4X:
     m.Put("notification", iosalert)
     m.Put("priority", 10)
in my send message SubRoutine in order to create a notification in the iPhone App?
But in this case it's not needed the prefix "ios_" in the Topic, right?
Other question: what consequences has the field "notification" for an Android App receiveing this kind of message?

Thanks
 

Erel

Administrator
Staff member
Licensed User
in my send message SubRoutine in order to create a notification in the iPhone App?
Yes.

But in this case it's not needed the prefix "ios_" in the Topic, right?
No, assuming that the device was subscribed to a topic that doesn't start with ios_.

Other question: what consequences has the field "notification" for an Android App receiveing this kind of message?
I don't 100% remember. You will need to check it.
 

Alpandino

Member
Licensed User
I don't 100% remember. You will need to check it.
I checked it: If I put the notification payload in the message, Android redirect this payload on the system tray if the App is in background, otherwise the app will consider only the data payload.
Reading this I noticed "on iOS 10 devices, you'll need to handle applicationReceivedRemoteMessage", but I can't see this Sub in the code of the first post. I can only see the code for notifications:
Sub Application_RemoteNotification
Someone can explain why? I think that without the "applicationReceivedRemoteMessage" Sub is not possible to receive any message....
 

Daniel Uribe

Member
Licensed User
Hi everyone!!

Good morning, If we want to show a specific module when the user click the notification, is possible?

Thanks a lot!!!
 

fransvlaarhoven

Active Member
Licensed User
Hello,

I just started with Notifications using the example code in the first post and noticed something strange:

- when the app is active and I send a notification, the event Application_RemoteNotificationis triggered showing the details of the notification.

- when the app is in the background and I send a notification, the notification shows. When I select the notification, the app is started and the event Application_RemoteNotification is triggered.

- when the app is in the background and I send a notification, the notification shows. When I start the app by pushing the icon of the app, the event Application_RemoteNotification is NOT triggered. It is only after selecting the notification that the event is triggered.

Is this normal or am I doing something wrong?
 
Status
Not open for further replies.
Top