I would like to know if it's possible to force the "XXXXX would like to send you push notifications" popup from within an app, after an initial decline. The use case is as follows:
The user installs the app, gets the alert about push notifications,
and declines because they don't know/trust the app yet.
They use the app and proactively request within the app to be alerted
when something happens (say for example something they want to buy is
sold out so they want to be alerted when it is back in stock).
So now the user has asked the app to notify them about something
specific but has push notifications disabled at the operating system
level.
So if the user requests an alert, but I detect that they declined
alerts on first run, I need to notify them of this and have them turn
push notifications on for the alert to work.
Ideally, I would like to force the "XXXX would like to send you push
notifications alert" at this point (a second time since they
installed the app).
I guess plan b would be to show them my own message telling them they
have to go into their system settings and turn it back on manually in
order to receive the alert they want. This is far from ideal.
Any help would be appreciated. Thanks.
You can't make iOS show the alert again. Here's a better approach:
Keep a flag in your NSUserDefaults indicating whether you should register for push notifications at launch. By default the flag is false.
When you launch, check the flag. If it's true, register immediately. Otherwise, don't register.
The first time the user does something that would cause a push notification, register for push notifications and set the flag in NSUserDefaults.
This way, when the user gets the push notifications alert, he has some idea why he's getting it, and might actually say yes.
I am also facing a similar kind of issue. After searching so much, I decided to do what you call Plan B. That is, show the user my own alert saying that push needs to be enabled for better experience, or something like that.
To check that required push types are enabled, use this method:
- (UIRemoteNotificationType)enabledRemoteNotificationTypes
UIApplication reference
I think that this is the clean solution. Consider a case where after accepting the request at first, the user turns off push, this thing will work even in that scenario.
The best way to do it would be to (if you're making a game) ask them a preemptive question (e.g. Do you want us to notify you when your crops are ready to be harvested? -Yes -No), and when they answer "yes", then fire the native iOS push popup. then you can layer in multiple questions along the user funnel, and you'll eventually catch them all.
Related
I am developing an application in which I want to snooze the received notification automatically for 10 mins, if user didn't take any action (neither dismiss notification, nor opened the app) on the previously displayed notification. This is required in iOS
You can't do that. Have you ever seen an app behave that way? No, because it's impossible (and incoherent).
Think of it this way. If the user does nothing, your app gets no signal that the notification fired. So it cannot "do" anything in response. You cannot respond to something that didn't happen.
Here's another way to look at it. When the notification fires, your app might not even be running. If the user does nothing, your app still won't be running. So how can it "do" anything?
In a comment, you referenced an app that has an "autosnooze" feature. But that app likely isn't snoozing in response to the fact that the user didn't do anything. It is scheduling a repeating notification (or multiple notifications) in advance, so the repetitions are already present when the user does nothing. When the user does respond, the app deletes the extra scheduled notifications. So you see, as I said before, the app responds to something that the user did do, not to something the user didn't do (though I can see why this behavior might give the illusion that it does what you asked to do).
I want to develop an app, but before I actually start developing, I've been doing some research so that i can be sure it's going to work in the way I'd like to do this.
You can imagine the app as a kind of news app, where the user can indicate whether he wants to receive push notifications, and may also indicate that he only wants to receive a push notification if it is in X distance from his current location.
And this is probally a problem on IOS, On android it would be no problem if a push notification came in to read the current position of the user and settings and then show the push notification or not.
As far as I've read this is a problem on iOS, the system receives the push and the app can not respond to it unless the user clicks on it.
Theres also another problem about closing an app on IOS, ideally a app should not be closed (swiped out) by the user because this would be a force close on IOS.
From ive seen most users still swipe out apps, and this would mean that my app cannot run background tasks anymore.
This is what i thougt about:
Send Silent push, app download data on the background -> Check if this meets the user settings, if so show a local notification. (30 sec time to handle, but do not know if it is possible to throw a local push here too.)
The app sends data on the background over the user's current position before sending a push, the server checks for which apps it should be sent (actually no solution, too much data usage as it may be that the user is only one Specific location, need a good server if the app is used on thousands of devices.).
Does anyone have any idea how to handle this problem?
In my settings tabbar:
I have a feature specific switch which can be turned OFF or ON based on API response.
From website only admin is authorized to turn ON/OFF.
I can make /user API call everytime on settings tap to check the current settings for the user but there are couple of disadvantage like if user is already on setting then it will not update the UI and calling api everytime on settings tap doesn't sounds a perfect solution.
I think better solution is to send a silent push notification which i can use to make the API call to update the settings UI whenever needed.
But if user has disabled the push notification will I still receive silent push ? What is the recommended approach to handle such situations ?
Short answer, yes
The exciting new opportunity for app developers in iOS 8 is that Apple will now deliver “silent” pushes even if the user has opted out of notifications. Also, “silent push” is no longer just for Newsstand apps. Every app can take advantage of this ability to refresh content in the background, creating the most up-to-date, responsive experience possible, the moment the user opens the app.
Although...
Users still have the ability to switch off your app’s ability to process a “silent push” by means of the “Background App Refresh” control. Even though Apple Push Notification service (APNs) will deliver a push marked “content-available” to your phone, the OS will not wake up your app to receive it, effectively dropping it on the floor. However, opting out of “Background App Refresh” is a lesser-known capability not directly associated with Notifications. You don’t access this preference in your Notifications Settings--it’s located under General > Background App Refresh screen.
Keep this in mind when building your application.
Source:
https://www.urbanairship.com/blog/watch-list-ios-8-opt-in-changes
This matrix might help. At left hand side, it shows if "didReceiveRemoteNotification: " method will get called or not. Other two columns is related to setting app. Settings -> YourApp. If yourApp supports Notifications and background app refresh. Look into matrix to check when you app will receive silent push.
Other answers are good. But they are not official answers.
The official answer is in What's New in Notifications WWDC 2015 video:
Silent notifications are enabled by default. The user does not need to
approve your -- does not give permission to your app to use them, and
you can just start using them without asking the user for permission.
But silent notifications are the mechanism behind background app
refresh. At any point you know that the user can go in settings and
disable them. So you can't depend on them always being available. You
don't know if the user the turn them off, and you are not getting a
notification anymore. This also means that silent notifications are
delivered with the best effort. That means that when the notification
arrives on the user's device, the system is going to make some
choices.
For more see this image and this answer
Is there any way to detect what user choose when promoted with the "allow push notification" dialog?
I want to catch what user choose at the moment he tap one of the dialog buttons ("Allow" or "Don't Allow")
any why I can do this?
I'm afraid not. While you can determine whether notifications are enabled (using UIApplication's isRegisteredForRemoteNotifications method), this does not tell you why notifications are not registered when they aren't.
It could be for any of the following reasons:
• The user has never been prompted for them.
• The user has specifically declined them.*
• The user approved them at some point, but has since turned them off.*
It's unfortunate that Apple does not provide a means to detect a user declining push notification registration when prompted. I suspect this is a conscious design decision intended to make it less likely for developers to harangue users.
I hope this helps.
(* ...you could infer which of the second and third options applies by storing a persistent flag upon the first registration, but this doesn't seem to be what you're asking for...)
There is no direct way of doing this, but I've implemented a workaround: APNPermisionRequest.
The interesting part here is to add an observer for UIApplicationDidBecomeActiveNotification and then show the request. After the notification is fired (ie. the request was answered), you can check for the status using [[UIApplication sharedApplication] isRegisteredForRemoteNotifications].
Is it possible to postpone the first time app startup request, about allowing apple push notifications: "X would like to send you push notifications" ("Don't Allow / OK")
I seems to remember having see apps before, where the request first popped-up after a pre conditional action. Is it possible to postpone the request from startup to a time where the user has done a pre conditional action, and the user then knows why they should/shouldn't allow push notifications for this app?
It is also regarding the thought that most people would reject it, if it is the first thing that pops up after they opened an app for the first time, and they have no idea why the should allow it.
Just call
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:notifTypes];
when you want the user to enable push for your app.
That's when the popup will show.