Setting app defaults for iOS 5 Notification Center - iphone

Does anyone know how an app can control its defaults in iOS 5 Notification Center? I have written a timer app using local notifications to alert the user when the timer goes off in background. When I upgraded to iOS 5, all notifications (alerts, sounds, lock screen) reverted to “off”. Needless to say, this is a terrible default setting for a timer app.
I’ve seen this happen with other apps, such as OmniFocus under iOS 5, but I’ve seen other apps like Pomodoro default to reasonable Notification Center settings.
I’ve checked the iOS 5 docs, notably the iOS 5 App Programming Manual, and the iOS Human Interface Guidelines, but haven’t found any information on this topic.
Has anyone discovered any pattern at all to the default settings?

Apparently, the app has to register itself with the Notification Center to be listed there; and then enabled by the user.
When I moved to XCode 4.2, my app did not show up in the notification center and I freaked out! Looking on the web a bit, I found the answer.
I have this code in the app's AppDelegate and all is fine now:
// Register the app for the Push- and Local-Notifications on iOS5 - else the users will not get the Local-Notifications
//
[[UIApplication sharedApplication]registerForRemoteNotificationTypes: UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeAlert |
UIRemoteNotificationTypeSound];
Sam.

As far as I have discovered, it is not possible to edit the Notification Center Settings from a third party App.
I really hope Apple releases an update that addresses this issue. I also have a birthday reminder App that is totally useless unless the user edits the Notification Center Settings manually .

Related

Make phone call from Apple watch app

Can we use a button to make a phone call from the apple watch app?
For iPhone app we can use once the button is pressed:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"tel://1111111111"]]);
openURL is silently ignored if the device is locked or the app is in the background. Additionally WatchKit doesn't contain an API for initiating a phone call.
Your best bet may be to prompt the user to open the iPhone app, possibly using Handoff, and tap a button to initiate the call from there. Not a great solution, but WatchKit is pretty limited right now.
It's now possible from WatchOS2 :
if let telURL = NSURL(string: "tel:5553478") {
let wkExtension = WKExtension.sharedExtension()
wkExtension.openSystemURL(telURL)
}
cf1,
cf2.
You can't do this on Apple Watch itself. But there alternative ways like:
Tell the user to call the phone in the companion iPhone app
Use Handoff to jump from Apple Watch app to the companion iPhone app with just a tap on a button (a more user-friendly way)
NOTE: The best way is always waiting for new versions. In WWDC 2015 taking place in San Francisco (June 8-12), they will introduce WatchKit 2 with support for the companion kits on iOS and the native watch apps that run on Apple Watch without having the iPhone nearby.

Newsstand App download when app is closed

I am implementing a newsstand magazine app, which receives new issues via Urban Airship push notifications.
This works fine, as long as the app is in foreground or background, but as far as I know, the download should also be triggered when the app is completely closed. But sending a push with "content-available":1 in the payload does not do anything if my app is closed.
I set the required background mode in the targets properties and I use NKDontThrottleNewsstandContentNotifications to avoid problems with testing.
Am I missing something?
Shouldn't the push lead to my
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
being called with UIApplicationLaunchOptionsRemoteNotificationKey?
Help much appreciated!
As per this article,
developers that are developing Newsstand apps can deliver a new “souped-up” push notification that informs their app (rather than the user as push notifications normally do), that a new issue is ready to be downloaded. When a Newsstand app receives such a notification, it can download in the background if the device is on WiFi. The main limitation here is that each app can only send 1 of these push notifications per day, so at the moment developers cannot develop newspapers that deliver both a morning edition and evening edition – although I suspect this might change eventually.
So it can download only if the device is on Wifi.
These are other similar questions, new stand push and execute code, iOS newsstand: push notification does not launch the app in background, Newsstand restarts the download on Resuming and this iPhone Newsstand push registration Failure. Check if you are missing anything mentioned in those answers as well.
Here is the apple documentation on this and another blog on this.

go to AppStore update screen from an iOS application

Is there a URL I can launch from the app that will take the user to the "Updates" tab in the AppStore application on an iOS device?
I'm not sure if it's possible to link directly to an update. I've found once an advice to replace "viewSoftware" to "viewSoftwareUpdate" on:
https://devforums.apple.com/message/139548#139548
but since link for "phobos" is no longer used it might not work any more
Here's the one we use for our apps (where "id" is the id for your app):
itms-apps://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftwareUpdate?id=438596432&mt=8
It mostly works. On an iPhone & iPod it goes right to the Update screen. On an iPad it goes to the store and shows an obscure error message. I filed that as a bug with Apple a few months ago.

iPhone application reset

I have a strange problem with my iPhone app.
I use geolocation and push notification. Everything is ok, but I want to test from scratch on the iPhone (connected to xcode debugger)... and I can't re initialized the iPhone.
I explain: I remove the app from the iPhone, and after re-installing the app (with xcode or with iTunes), I launch the app, but iOS doesn't ask me to approve geolocation and push notification as it does the first time. In fact, it seems to 'remember' my choices.
As I need to debug this (Some users have problem on running app the first time), I'm blocked.
Thanks by advance for yours answers
There's a place in the Settings app to reset Location permissions.

Reset push notification settings for app

I am developing an app with push notifications. To check all possible ways of user interaction, I'd like to test my app when a user declines to have push notifications enabled for my app during the first start.
The dialog (initiated by registerForRemoteNotificationTypes), however, appears only once per app. How do I reset the iPhone OS's memory of my app. Deleting the app and reinstalling doesn't help.
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
Another just for testing solution to this is by simply changing your bundle id. Just don't forget to change it back once you're done!
On iOS 9.0.2, I'm getting the "register push notification alert" every time I delete the app and reinstall it. This is true for both AppStore production downloads and adhoc mode.
UPDATE: It is confirmed this is working for iOS 9.x
As already noted the approach for resetting the notification state for an app on a device is changed for iOS5 an newer.
This works for me on iOS6:
Remove the app from the device
Set the device datetime two days or more ahead
Restart the device
Set the device datetime two days or more ahead
Restart the device
Install and run the app again
However this will only make the initial prompt appear again - it will not remove any other push state related stuff.
The plist:
/private/var/mobile/Library/RemoteNotification/Clients.plist
... contains the registered clients for push notifications. Removing your app's entry will cause the prompt to re-appear
Doing it programmatically seems to work for me everytime.
I have a build with the following line uncommented:
[[UIApplication sharedApplication] unregisterForRemoteNotifications];
I run it every time I want to unregister from PN. You might have to end the app explicitly from the recents list and play around with the Notification Center in Settings app to get it right.
Also, the UI prompt asking the user to register for PN may not show up. Not sure if has been disabled in any of the recent iOS versions.
I agree with micmdk.. I had a development environment setup with Push Notifications and needed a way to reset my phone to look like an initial install… and only these precise steps worked for me… requires TWO reboots of Device:
From APPLE TECH DOC:
Resetting the Push Notifications Permissions Alert on iOS
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 following these steps:
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.
As ianolito said, setting the date should work:
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.
I noticed on my device (iPhone 4, iOS 6.1.2) setting the system clock a day forward or even a few days did not work for me. So I set the date forward a month and then it did work and my application showed the notifications prompt again.
Hope this helps for anyone, it can be kind of head aching!
I have wondered about this in the past and came to the conclusion that it was not actually a valid test case for my code. I don't think your application code can actually tell the difference between somebody declining notifications the first time or later disabling it from the iPhone notification settings. It is true that the user experience is different but that is hidden inside the call to registerForRemoteNotificationTypes.
Calling unregisterForRemoteNotifications does not completely remove the application from the notifications settings - though it does remove the contents of the settings for that application. So this still will not cause the dialog to be presented a second time to the user the next time the app runs (at least not on v3.1.3 that I am currently testing with). But as I say above you probably should not be worrying about that.
The same tech note as refered to in the accepted answer (TN2265 - Troubleshooting Push Notifications) has since been updated with a solution for iOS 5 and above.
In short: create a backup and restore from it every time.
On iOS 5 and later, reset the push notifications permissions alert by restoring the device from a backup (r. 11450187). Here are the steps to do this efficiently:
Use the Xcode Organizer to install your app on the device. The key is to install the app for the first time without running it.
Use iTunes to back up the device.
Run the app. The push notifications permissions alert will be presented.
When you want to reset the push notifications permissions alert, restore the device from the backup you created in the first step.
The Apple Tech Note also described you can restore the device to reset the Push Notification dialog.
It does not say that you can also use the option "General -> Reset -> Erase All Content And Settings" on the device itself (iOS 5.x).
I recently ran into the similar issue with react-native application. iPhone OS version was 13.1 I uninstalled the application and tried to install the app and noticed both location and notification permissions were not prompted.
On checking the settings, I could see my application was enabled for location(from previous installation) however there was no corresponding entry against the notification Tried uninstalling and rebooting without setting the time, it didn't work. Btw, I also tried to download the Appstore app, still same behavior.
The issue was resolved only after setting the device time.
In addition to the answer of ianolito.
Had the same issue with an app I downloaded a year ago and denying push notification initially. Now wanting push notifications back, these steps worked for me on iOS 7 beta. Not sure which point(s) triggered it exactly.
Close and delete the app.
Go to your iCloud settings and delete the app from the iCloud. Do this on all other devices where you have iCloud backup for apps enabled. After deactivating and deleting make a fresh backup. The app should not be listed any more under the backups. (This is maybe why the Technical Note from Apple described by ianolito stopped working in iOS 5, since iCloud was introduced in iOS 5 and many have iCloud backup for apps enabled.)
Go to your time settings and set the time more than 1 month ahead.
Switch the iPhone off (no reset).
Wait a minute, switch it on again and download the app again.
Start the app and I was presented the dialog again.
Enable app backup again, since it is still deactivated. Correct the time.
Thank god I did not have to "Erase All Content And Settings". Maybe it will help someone.
After hours of searching, and no luck with the suggestions above, this worked like to a charm for 3.x+
override func viewDidLoad() {
super.viewDidLoad()
requestAuthorization()
}
func requestAuthorization() {
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { (granted, error) in
print("Access granted: \(granted.description)")
}
} else {
// Fallback on earlier versions
}
}