1

I'm trying to implement a messaging sub system in a multi platform app for web and mobile using Firebase Cloud Messaging (FCM). FCM allows you to send messages in two formats: Notifications and Data.

Notifications are shown by the platform, eg. in a little popup on the web platform or added to a list of notifications on your mobile phone.

Data messages are handled by your application.

Before the app can receive messages, you have to ask the user for permission to send/receive notifications.

Now, when the user blocks notifications, data messages seem to be blocked as well. Am i missing something, or is this by design?

Ralf Bokelberg
  • 405
  • 5
  • 9
  • 1
    I think this is by design so it should be expected. Permissions are there to give power/control to the users on what happens in their device. It doesn't look good if the apps that are blocked to still be able to send notifications, it kinda makes the permissions useless, if it were to happen. – AL. Feb 21 '17 at 11:03
  • 1
    Yeah, thanks for your comment AL. I guess it does make sense. I was looking at FCM as a more general messaging infrastructure, with the option to connect to the notifications api of the target platform. Apparently it is not an option but an integral part of it. Would you agree? – Ralf Bokelberg Feb 21 '17 at 11:11
  • FCM is mainly and simply a push notification service. So yeah, it is an integral part. – AL. Feb 22 '17 at 02:01

1 Answers1

2

In the context of iOS, permissions are only needed to show push notifications in the notification center.

UIApplication.shared.registerForRemoteNotifications() will allow you to retrieve the device token, but will not present a permission alert. At this point, you can receive push notifications, but you won't see them unless you print them out in didReceiveRemoteNotification, or in the case of Firebase data messages, didReceive remoteMessage.

In order to show notifications outside of the app, you would need to call UIApplication.shared.registerUserNotificationSettings(settings) which will present a permission alert.

Corey W.
  • 319
  • 3
  • 9