I am using APNS service in my universal app (iPhone/iPad) and i am not geting notifications on device. Previously i was getting notifications perfectly but now a days with the same code at server side and client, it is not working.
On server side notification status is delivered but i am not receiving it on my device.
I have checked most of the questions on stackoverflow but i was unable to find my question. one guy said that in development environment it may have delays, but my problem is that i am not receiving notifications at all.
Note: i am using sandbox environment not production.
Just in case you haven't found a solution yet, one additional thing you could check is if your device's date and time is properly set (in the OS). If your iPod, iPhone or iPad isn't set to the current date, we found that notifications are ignored silently. Of course, there are many other possible explanations as to why your service stopped working, but this is a simple thing to check when everything else appears to be fine.
Following are the things you can check
Check the entitlements while codesigning the app. (They can be seen in Xcode build log).
Check whether notifications are on for the device in the settings menu.
If you are using corporate network on the iOS device, the push notifications might be blocked. Try using a different network.
After launching the app, check the organizer for any logs with the reason why push notifications can not be enabled.
I hope some of this helps you out.
I just revoke my certificates
Uploaded new certificates deleted all provision from my organizer
and then created new provisions and installed them on my system.
At the same time I got my APNS working.
Related
I have a very unique situation here, I have to test devices with same specification. The application i have developed has push notification capability enabled. All configurations are done in server side i.e added device as development device, the device is added into provisioning profile, the provisioning profile is installed in phone and development machine as well. Now the problem is the application is installed in both the device in one device everything works perfectly fine the notification appears for every event, however in another device it doesn't.
I tried everything i.e checking the setting in device if for some reasons notification is not allowed or may be some settings. I compared all the settings in both the devices everything is same.
The error I get in server side is Bad Device Token for one device. I tried to delete the token from server side and got it again still same situation it works for one device but not for other.
Any help or pointer would be really appreciated.
I've been developing and uploading apps for some months. Whenever they needed being uploaded to the app store, I could do it without problem, but now, I'm stuck with one that doesn't want to be validated/uploaded. XCode says "the request timed out" after MANY minutes with a spinwheel on screen.
The differences between my old updates to the app store and the one I'm trying right now are:
-Xcode 4.X before, Xcode 5 now.
-I had to recreate the app store certificate/provisioning profiles, because they just expired.
-I inherited this project from other coworker (not here anymore) and maybe my "developer profile" is somewhat conflicting with some certificates, etc... (Still many dark areas for me).
I've kind of tried "everything". Erasing provisioning/profiles, closing Xcode, resetting, cleaning my project. But no luck. My current Xcode 5 is able to compile my app perfectly, I'm even able to select the distribute option before uploading (the app is ready to be uploaded onto itunes connect), I even login with my client credentials onto itunes connect, I can even select the correct provisioning profile (app store profile, not a developer one), but no luck:
If I choose to upload or validate, Xcode just complains with some kind of "dull" timeout error.
Any hints? Any way to debug what happens behind the curtains?
Greetings, I'm at a loss.
EDIT: Apparently, the timeout failing event appears in the validation process. If I try to upload, the status log says "Failed Validation". If I try to validate, obviously there's also a "Failed validation" error. Where can I find some log to see what part of the validating process is failing?
Well, apparently: "Problem solved".
After 2 boring days trying to upload my app (via Xcode 5, and via Application Loader), I've discovered that Apple upload servers seem to be overloaded (unless a better explanation arises).
I'm in Europe, and from 9 to 14 h my app was ALWAYS rejected. But once I tried it after 16h, the upload and validation processes worked like a charm (both with Xcode 5 and with Application Loader).
Why this? No idea, but I didn't change anything in my upload process, so it's sad, but the solution is:
"Have patience, and wait to upload your app on a time slot where Apple upload servers are not overloaded". The sad part is: No one knows WHEN is that time :)
I solved it by switching Internet provider.
I simply connected my laptop to my iPhone via Personal Hotspot and used LTE network to upload the app.
It worked for me twice.
for Xcode 13 and Mac OS Big Sure
Install the "Transporter" app from the MacOS app store.
From Xcode's organizer, select your archive and press "Distribute App"
Instead of "Upload", select "Export" and proceed as usual.
Drop the exported .ipa into the transporter and press "Deliver".
In my case I changed the dns server from my provider to the google dns server (8.8.8. and 8.8.4.4).
I think you can try any other, if your providers dns or what ever doesn't work
Faced the error many times, not sure why.
Try this
Export the ipa after the archive
Add and upload in Transporter
I get 100% success in uploading and feel a little quicker than Xcode's upload.
I actually called Apple Developer Support about this and they solved the problem!
It turned out that my recovery email address in my Apple ID (not the main email address but the recovery one) was not verified. They had me go to http://appleid.apple.com, login with my Apple ID, and then go to the 'Password and Security' section (on the left).
After answering my security questions I was able to resend the verification email, and once verified I was able to log in on Xcode straight away!
I have the observation that with Mavericks and App Nap enabled, a hidden Organizer window within XCODE will cause the network connection to be dropped.
Even if the window is occulated (hidden) for just a second).
Make sure the window is always visible and the problem does NOT occur.
We recently launched an update to an iPhone application. While our push notifications were working perfectly in ad-hoc, we've moved to live and they are no longer registering.
Looking at a live device log, we're seeing this:
"Jun 11 09:40:05 unknown SpringBoard[5791] : No valid 'aps-environment' entitlement string found for application 'App Name': (null). Notifications will not be delivered."
Now if you check on the internet or other stack-overflow conversations, there is a very common answer to this that the provisioning profile did not have "aps-environment" set as "production" correctly and the profile needs regenerating. However, this does not appear to be our issue as the binary clearly indicates it is in production aps environment. See details from the App Store Binary Details below:
So we are a bit lost for what the problem could be. Given this information, as well as numerous checks I have done on my side, the profile and code signing appear to be correct and I can't find any other solutions to this online at the moment.
Thanks in advance for your help.
So this problem worked itself out in the span of 3 hours; it must have been a server propagations issue.
To anyone who might pull their hair out in the future on this one: If your app JUST went live and the notifications aren't registering and you are certain that the aps-environment is set correctly, wait a few hours prior to concluding that the app has an issue.
Our app was launched in the Canadian iTunes Store only and the push notification registration issue resolved itself within a 3 hour period.
If anyone in the future can explain why this happens or add more detail to this, I'll gladly accept their answer.
I have asked this question on the Apple DevForums, too.
If I get an answer there, I'll share it here, too.
The problem is:
We have installed the same AdHoc app on our iOS 4 (good thing that we didn't update all of them to iOS 5) and iOS 5 devices.
The PN is received on the iOS 5 device, but nothing happens on iOS 4.
We triple checked everything on the server, in the app and on the devices. Still it works only on iOS 5.
Did anyone encounter this issue?
Thanks!
Also you will not receive Push notification if your iPhone is jail-breaked.
And it's good idea to check are you using developing or production certificate and device token.
Did you check wether you use the right APN certificates?
You should make sure that you use the right certificate to the right address.
The sandbox mode is not the same as release mode. So you will get from the apple server 2 different push token.
To make sure wether you are doing correctly, I suggest you to try http://mobiforge.com/developing/story/programming-apple-push-notification-services
Sometimes the Push also delays till 1 hour. Keep this in mind.
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
}
}