0

I'm using FCM (Firebase cloud messaging) to receive push notifications.

Everything is working for me.

But from my server side they will send notifications continuously to my app with time as body up to some time.

Now I have to push notification only once where the time I am getting from server reaches current time.

Before current time and after current time notifications should not be shown.

I don't have any idea how to do this.

Can any one explain if is there any way to get this.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Himanth
  • 2,381
  • 3
  • 28
  • 41
  • 4
    It isn't exactly clear what you are asking, but push notification is a "best effort" service; there is no indication that a message has been delivered – Paulw11 Sep 21 '16 at 10:01
  • You must send silence notifications. And then show local notification when u need. Look here: http://stackoverflow.com/questions/20741618/didreceiveremotenotificationfetchcompletionhandler-not-being-called-when-app-is – Dmytro Shvetsov Sep 21 '16 at 10:33
  • @DmytroShvecov How can I differentiate between silent notification and push notification? – Himanth Sep 21 '16 at 10:35
  • Silence notification will not shown to user. You must send all notification in that way. And handle them in program, and then show local notification if needed. look at link what i posted before – Dmytro Shvetsov Sep 21 '16 at 10:38
  • @DmytroShvecov Thanks for the responce – Himanth Sep 21 '16 at 10:39
  • @DmytroShvecov But if i got silent notification from server how can I push notification to user? – Himanth Sep 21 '16 at 10:48
  • I just not exactly understand what you want, and what you asked, like mention first commentator). You can show notification to user with UILocalNotification. – Dmytro Shvetsov Sep 21 '16 at 11:11
  • From a deleted answer comes this link to a very related question: http://stackoverflow.com/questions/25830597/how-to-know-push-notification-delivery-status/25830955#25830955 – Frank van Puffelen Sep 21 '16 at 13:52

2 Answers2

1

You can customize you notification arrival schedule by implementing cron jobs on your server.

And if you are using any API to push notification to any device just get the success message or delivered message after calling.

vaibhav
  • 4,038
  • 1
  • 21
  • 51
1

I have created an endpoint on a PHP server that takes an autoId referring to a notifications/$autoId in my realtime database. The sender of the notification writes the notification data to the database and if successful sends a POST request to http://myserver.com/notifications/$autoId/send.

This seems authentication-less however no one will know the notification id being sent apart from the user who created it and the user who receives it. On the server side, when the message successfully sends using FCM, we can set {"sent": true} to prevent it from being sent more than once. When the notification is received by the user, we set {"received": true}.

{
    "notifications": {
        "$autoId": {
            "sent": false,
            "received": "false",
            "userInfo": {
                "notificationId": "$autoId",
                "toId": "$toUid",
                "fromId": "$fromUid"
            }
        }
    }
}
Callam
  • 11,409
  • 2
  • 34
  • 32