0

i have used notifications in many of my apps but all of them were using firebase, web backend using php script to send notifications. But i also got fcm to send notifications to particular topics using swift code. But what i want to do is that i want to send notification to a device via swift code. I dont want to use firebase console or webserver to send push to my iOS device. I want to handle all that inside swift code. If you please help me with this. I am really confused even if this is possible at all or not. I mean just select a device token from firebase storage and tap a button to send notification to that devixe. I hope you understand. I will be looking forward to help thanks.

Salman Ali
  • 255
  • 6
  • 24
  • 1
    This isn't possible. Notifications are pushed from an Apple server. The only alternative is to schedule a local notification https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ – iwasrobbed Jul 10 '17 at 03:09
  • Suppose i have an online database. In my swift code i listen to the changes made to the database. When someone changes the database, can i trigger local notification if in the background? – Salman Ali Jul 10 '17 at 03:11
  • You cannot send notifications directly between devices. See https://stackoverflow.com/questions/37634046/is-it-possible-to-send-pushnotifications-using-firebase-cloud-messaging-fcm-t, https://stackoverflow.com/questions/37435750/how-to-send-device-to-device-messages-using-firebase-cloud-messaging and more from [this list](https://www.google.com/search?q=site:stackoverflow.com+ios+firebase+notification+device+to+device). – Frank van Puffelen Jul 10 '17 at 03:12
  • You can use Cloud Functions as the server component. For an example of doing this to send push notifications, see the first use-case here: https://firebase.google.com/docs/functions/use-cases#notify_users_when_something_interesting_happens. Also see this blog post, which uses topics to target messages: https://firebase.googleblog.com/2016/08/sending-notifications-between-android.html – Frank van Puffelen Jul 10 '17 at 03:13
  • No, because you can't guarantee the person will have your app open when a database change is made. The point of remote notifications is to notify consumers of a change on your server and get them to open your app. Local notifications are for reminders and other recurring events that the consumer typically schedules themselves. – iwasrobbed Jul 10 '17 at 03:13

0 Answers0