I want to know if I can receive payload from FCM in my iOS app, even if the user doesn't allow notifications for my app. I don't want to show them as notifications, i just want to handle their payload.
Does background messaging work without permission?
Does foreground messaging work without permission?
The Firebase Cloud Messaging APNs interface uses the Apple Push Notification service (APNs) to send messages up to 4KB in size to your iOS app, including when it is in the background.
Notification permission is required for both background and foreground work (even if your push notification is a silent one i.e no notification needs to be displayed)
You still need the user to allow the notifications, later on, you can implement the handling as silent or not, up to you.
In order to receive the payload you need, it must come from a push notification.
Related
Is there any way to handle remote notification payloads before they’re delivered and display in notification centre?
With push notifications of default type there is no way to filter out notifications if the app is not in foreground.
The possible solution to this is to use VoIP push notifications in conjunction with PushKit.
VoIP pushes are always waking up the application, however they are not presented to the user and don't modify app badge value, so it's up to the developer to show a local notification upon the received VoIP push and to deal with app badge.
There is a technique with additional silent push that for example Facebook is using, to delete notification on iOS device when the message has been read on desktop web site. It's described here: https://www.pushwoosh.com/docs/deletable-ios-push
With the introduction of new HTTP/2 APNS interface, same certificate will work for background voip apps which would be identified using apns-topic under extension '( 1.2.840.113635.100.6.3.6 )'. That means if my app's bundle id is 'com.Sample.myApp', then I can use 'com.Sample.myApp.voip' to specify voip app.
Having said that, do I still need to implement Pushkit framework to make sure notification is directly delivered to my app to avoid any user intervention to accept the notification?
Also, as per my understanding server side (apns provider) implementation remain same with respect to delivering voip or regular push notifications using single certificate & same interface when talking to APNS using HTTP/2 API. Please correct me if my interpretation is wrong here.
Regards,
_Ayush
You can use same bundle identifier, Just make sure provisioning profile must have selected with VOIP. else you would not get notification.
Yes, you need to implement Pushkit framework. if and if your app is related to VOIP. This helps specifically in silent push notification, that does not come in notification tray, but make active your app in background mode. ( would not invoke or come in foreground )
For example - If your app is like Skype.
Once you get incoming call notification, when you gets missed call notification, incoming call notification gets cancelled ( Removed from notification tray )
Getting silent push notification though push kit, you can schedule local notification, while getting another ( missed call ) notification you can remove earlier local notification and schedule missed call local notification.
Thanks.
I am trying to make an app where you could send a warning to other users which then will trigger an alarm on the receivers phone.
So my plan is to send a silent warning to the receiver, which then triggers sounds and vibrations on the receivers phone from the app.
So basically my question is, is it possible to open an app on a phone through a silent push?
This is done with push notifications in iOS. See Apple's description.
Apps must be configured appropriately before they can receive local or remote notifications. The configuration process differs slightly on iOS and OS X, but the basic principles are the same. At launch time, your app registers to receive notifications and works with the system to configure that notification support. Once registration is complete, you can start creating notifications for delivery to your app. Your app then handles these incoming notifications and provides an appropriate response.
But note that it is up to the receiving user to determine how he wants to be alerted.
I created an app which receives push notifications from my server. At the same time, if some other app is sending push notifications (for e.g., whatsaap, twitter), the notification is getting displayed when I'm using my app. I want to hide all other app's push notifications except my app's push notifications. Can this be done in iOS? I want my app to receive push notifications only from my server but not from the other apps.
Thanks in advance.
Try to think like your customer. Would they like to receive the push notifications of the other apps (whatsapp, twitter, the notification that a very important email just arrived)? Of course they would. Your App is one of many and most probably not the most important one they own.
Let me provide some background first.
Your app can only receive notifications from your service/server.
The user might have apps that are receiving notifications from the respective service/server.
e.g. if the user has FB app, then it would be receiving notification from FB servers.
In the end, you are only responsible for managing your service/server.
There is no way for you to block notifications that are received from other services from your app.
Hope this helps.
I have an iOS app that needs to update its content while running in foreground automatically. My app does NOT need to update if in background.
There is a existing way to do so, which is APNS(Apple Push Notification Service).
Because I don't want users to see notification message while in background, using push notification without alert or message might be a solution.
However, if using APNS, iOS would ask users to confirm if they want to receive notifications by my app. I think that users may be confused when being asked by the OS since my app does not actually push notification to users.
The current method I use is keep pulling my API every 30 seconds to see if new content is available. This method would fail if there are too many users.
Is there any 3rd party push-notification-like service that provides notification while app runs in foreground only? (no need to get notification while in background)
You can use Silent notification for that, in this
In the WWDC 2013's "What's New with Multitasking" presentation, there is a section about Silent Push Notifications. if you send the APS payload with just the content-available set to 1, users will not be notified of the notification.
And the notification arrives in application:didReceiveRemoteNotification:fetchCompletionHandler:
Your payload is like
{
aps: {
content-available: 1,
sound: "default"
}
}
In case of push notification, it is necessary for user to accept push notification on application 1st run. You can set a silent push notification also and for this user will not get any alert of getting a notification during application run loop.
If you want to avoid push notification, then you can only set a NSTimer that you are doing already.
There can be a 3rd case, Application only sync with the server when it comes to foreground. And for this you can refer to my this post.