Reset push notification settings for app
Technical Note TN2265: Troubleshooting Push Notifications
The first time a push-enabled app
registers for push notifications, iOS
asks the user if they wish to receive
notifications for that app. Once the
user has responded to this alert it is
not presented again unless the device
is restored or the app has been
uninstalled for at least a day.If you want to simulate a first-time
run of your app, you can leave the app
uninstalled for a day. You can achieve
the latter without actually waiting a
day by setting the system clock
forward a day or more, turning the
device off completely, then turning
the device back on.
Update: As noted in the comments below, this solution stopped working since iOS 5.1. I would encourage filing a bug with Apple so they can update their documentation. The current solution seems to be resetting the device's content and settings.
Update: The tech note has been updated with new steps that work correctly as of iOS 7.
- Delete your app from the device.
- Turn the device off completely and turn it back on.
- Go to Settings > General > Date & Time and set the date ahead a day or more.
- Turn the device off completely again and turn it back on.
UPDATE as of iOS 9
Simply deleting and reinstalling the app will reset the notification status to notDetermined
(meaning prompts will appear).
Thanks to the answer by Gomfucius below:
https://stackoverflow.com/a/33247900/704803
ios10 custom push notification sound not playing
This problem seems to only affect apps installed via Xcode. The issue persists even if you later update the app from a different source.
The solution is to completely remove the app, and reinstall it from TestFlight or the App Store.
In effect, this bug should not affect your end users.
Edit 2016-10-15:
Unfortunately it seems that I was mistaken. This appears to be a bug on iOS 10 that can, in fact, affect App Store apps also. If it is of any consolation, apps such as Facebook and WhatsApp are affected too. The solution is apparently to force restart your phone, but unfortunately there doesn't seem to be much we can do about it as developers.
Apple Fixed Issue:
Based on this comment, Apple has seemed to fix the issue in iOS 10.2
Silent Push Notification in iOS 7 does not work
This works also and does not play a sound when it arrives:
{
aps = {
"content-available" : 1,
sound : ""
};
}
EDIT
People having this problem may want to check out this link. I have been participating in a thread on Apple's Developer forum that goes over all app states and when silent pushes are received and not received.
Notification Service Extension Not working
Finally I was able to resolve the issue. I am not sure what was causing the issue but after some experiments I realised that not only my service extension but all other installed app's service extension was not working and when sending the push payload with "mutable-content: 1, Notification was not displayed. After rebooting the device it started working fine. I was using iPhone 6s.
Local Notifications After Device Restart
The UNLocationNotificationTrigger
is a new helper classes added in iOS10 to make it easier to trigger notifications based on beacon or geofence detections. According to the documentation, it is designed to be used only when the app is in use:
Apps must request access to location services and must have when-in-use permissions to use this class. To request permission to use location services, call the requestWhenInUseAuthorization() method of CLLocationManager before scheduling any location-based triggers.
https://developer.apple.com/reference/usernotifications/unlocationnotificationtrigger
Based on the above permissions, the app will only trigger when in use. The documentation does not explicitly say that it won't work in the background, so you might try requesting always location permission with the requestAlwaysAuthorization()
instead of requestWhenInUseAuthorization()
(be sure you put the correct key in your plist if you do this), to see if this helps.
An alternative would be to not use this helper class and instead manually start up CoreLocation
and beacon monitoring, then create your own UILocalNotification
manually when you get the region entry callback:
func locationManager(_ manager: CLLocationManager, didEnterRegion region: CLRegion) {
if let region = region as? CLBeaconRegion {
let notificationMessage = "Wild IBEACON appeared!"
let notification = UILocalNotification()
notification.alertBody = notificationMessage
notification.alertAction = "OK"
UIApplication.shared.presentLocalNotificationNow(notification)
}
}
The above approach is known to work across app restarts.
Related Topics
Dismiss Keyboard with Swipe Gesture
Get Index of Object from Array of Dictionary with Key Value
Passing Data Between View Controllers Without Segue
How to Add .Plist File to All Targets in Xcode
Compiler Error When Assigning the Delegate for a Protocol in Swift iOS
Get Latitude and Longitude Center of Google Map
Libmobilegestalt Mobilegestalt.C:890: Mgisdeviceoneoftype Is Not Supported on This Platform
Swift Lazy and Optional Properties
Swift - Using Cgcontext to Draw with Finger
How to Execute a Function in a Uiviewcontroller Through a Swiftui Button
Include Pods in Main Target and Not in Watchkit Extension
Recognizing Touch Events Only Inside the Masked View
How to Handle Oauth-Style Log Ins with Imessage Apps in iOS 10, Xcode 8
Skvideonode Only on a Small Part of Scnsphere
Restkit, Coredata and Swift - I Can't Seem to Fetch Results Back Out
Saving Contact Address to Unified Contact Results in (Cnerrordomain Error 500)