EasyAPNS initially setting all flags to disabled - objective-c

We're using EasyAPNS to help us with push notifications in our iPhone app, being sent from our PHP web app.
On first installation of the app, the user sees the request to allow us to send push notifications, even if they select allow, all the flags are sent to the web server from the iPhone as 'disabled'.
If you terminate the app, and reopen it, when it sends the settings again... they are sent as the correct options (e.g., enabled)
We followed the steps exactly, with one small difference, that we are using
application:didfinishlaunchingwithoptions:
instead of
applicationDidFinishLaunching
As it's apparenly deprecated according to this
Can anybody shed some light on this, and point us in the right direction for a fix?

So if the user rejects push messaging, you will re-ask when the app is next used after termination? It may get a little annoying for the user to be asked the same question over and over again.
And you will have to ask for permission or else that user wouldn't be registered for Push.
Have a look at http://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html

Related

Push notifications not asking permission when user loads app

Hi I have just released my app update with push notifications added into it. I was worried that it would not work properly so I did a bunch of testing. First with just a development certificate and then a production certificate using adhoc. Both ended up working and I was pleased when the adhoc worked.
Anyways the update has been live for about 8 hours now and for some reason push isn't working. I checked with my friend and have realized that the user is not being asked whether he wants to accept push notifications from my app. Which means when the token gets sent to my server, its appearing as (null). I have no idea why this is happening. When he goes into device settings --> notifications ---> my app does not appear on any of the lists (receiving push notifications or not receiving).
This is the code in my delegate that should trigger the request:
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
If anyone knows why this is happening, input would be much appreciated. Thanks!
We thought we were having this same issue but found out that the app was actually working correctly. The user is only prompted once even if they uninstall and reinstall the app.
We were testing it by uninstalling the app and then reinstalling. iOS would remember how we had responded previously on that device and would not prompt again leading us to think there was a problem.
We found the best way to test is with the simulator and doing a "Reset Content and Settings".
After configuring your app for push notifications and generating your SSL certificates you must also generate new provisioning profiles.
The developer portal displays this message on the App ID configuration page:
After you have generated your Client SSL certificate, create a new provisioning profile containing the App ID you wish to use for notifications.
If you did not update your App Store provisioning profile after setting up push the OS will not provide you with a push token.
If this is your problem you just need to generate a new App Store distribution profile and submit a recompiled version signed with that profile.

iOS App and persistent login (Apparently an phone-specific AND app-specific issue)

I'm having a really strange problem. I've written an iOS/Rails app in which users have accounts, and need to log in to perform all kinds of actions within the app.
When the app launches, the app detects whether the user's username and password have been stored. If not, it prompts for login credentials. Anyway, logging in seems to be working perfectly, and the server sends back the appropriate response.
However, when I try to do anything else in the app that requires being logged in, I get an error from the server saying I don't have the login credentials. I didn't think I had to do anything special with the cookies (i.e. I thought they were stored automatically), but maybe I'm wrong?
If some code samples would help, let me know what snippets you'd like to see and I'll post them, but I feel like this is more of a conceptual misunderstanding on my part than anything else.
Any help is much appreciated!
EDIT: I tested the app on my friend's phone, and it works fine. It's only my phone which is having trouble with the app. I looked for any settings involving cookies, but because all the apps are sandboxed, changing settings with cookies in Safari, for example, won't help. I'm pulling my hair out with this issue. I've restarted my phone, deleted and reinstalled the app, and tried changing some of the code, without any success. The Facebook app works as expected, so I assume cookies are being stored in Facebook's sandbox. Only my app seems to be having this problem, but it was working yesterday. Any suggestions?
After you login you need to store the cookie which is returned. It will then be sent with every request afterwards.
Take alook at theses q's:
Objective-C Asynchronous Web Request with Cookies
Managing HTTP Cookies on iPhone
iPhone NSData/NSUrl with cookie

Sending requests when user answer "App wants to use location services"

I'm using Core Location in my app, app asks user if he wants to use Location services, but I use in my app async requests, so app doesn't wait while user answer "Ok" or "dismiss". Ho can I prevent this? I want that my request will be send when user taps "OK". Thank you
In iOS 4.2 and up, your delegate will receive a message locationManager:didChangeAuthorizationStatus: when the authorization status changes (i.e. the user responds to the dialog, or the user backgrounds your app and goes into Settings and changes the global location settings). If you support earlier versions, you'll have to fall back to guessing based on locationManager:didUpdateToLocation:fromLocation: and locationManager:didFailWithError: messages (especially the NSError code kCLErrorDenied in the latter).

Apple Push Notification Feedback Service - how frequently does it check

I have been able to successfully create push notifications and I have also received responses from the feedback service, so I am confident that my configuration is correct, but I was wondering, how long after a device has been made inactive, will it be picked up by the Apple Push Notification Service.
When I first polled the feedback service, I received details on devices which were inactive several days ago. Now, while testing, when I uninstall the application and occasionally poll the feedback service, I'm not receiving any results.
Any idea on how long it takes to update would be useful, as I'm no longer sure if the issue is else where in my code or if I'm just testing too soon.
Issues with Using the Feedback Service
If you remove your app from your device and then send a push notification to it, you would expect to have the device token rejected, and the invalidated device token should appear on the feedback service. However, if this was the last push-enabled app on the device, it will not show up in the feedback service. This is because deleting the last app tears down the persistent connection to the push service before the notice of the deletion can be sent.
You can work around this by leaving at least one push-enabled app on the device in order to keep the persistent connection up. Just install any free push-enabled app from the App Store and you should then be able to delete your app and see it appear in the feedback service.
source:
http://developer.apple.com/library/ios/technotes/tn2010/tn2265.html#TNTAG34
After further investigation elsewhere, I discovered people suggesting that for testing feedback service, there should be two instances of the app on the iPhone. Test the feedback service by removing 1 of these and then attempt to send notifications to this removed app.
When I do this, the feedback service responds very quickly.
I do not have exact timings, but on my system, it feels like it is responding straight away after I make a call to attempt to push a notification and then immediately make a call to the feedback service.

On a Mac how to determine a user logout is occuring

I am very new to the Mac platform and Objective-C in general and in my application I would like to know how to determine that a user is logging out and perform some actions prior to this. Any info or pointers for this?
The official way to put the hook at logging in / logging out is described in these Apple documents Customizing Login and Logout and Tech Note 2228. But I'm afraid that the log-out hook was no longer directly supported.
So, the second best way is to run a headless Cocoa app, and receive a notification from the system using NSWorkspace, see the document and the list of available notifications.
To make a headless Cocoa app, you need to set an entry in its Info.plist called LSUIElement, see here. By setting LSUIElement to be yes, the app don't appear in the dock, but perform various operation in the background.
Take a look at Receiving Workspace Notifications in this Workspace Services document.
NSWorkspaceWillPowerOffNotification
Posted when the user has requested a
logout or that the machine be powered
off.