0

My server needs to send an Apple Push Notification with an alert that goes something like, "Your driver will arrive at 2:45pm." It would be nice not to have to pull the user's time zone and time formatting preferences up to the server, and instead just pass some kind of universal point-in-time indicator (e.g. epoch seconds or UTC timestamp) and have the iOS device turn that into a timestamp in the user's preferred format.

Is this possible?

Eran
  • 387,369
  • 54
  • 702
  • 768

2 Answers2

2

Short answer - generally 'no.' Here is the Apple documentation:

If the target application isn’t running when the notification arrives, the alert message, sound, or badge value is played or shown. If the application is running, iOS delivers it to the application delegate as an NSDictionary object.

Since your application would generally not be running, you don't get a chance to interpret the contents of the APN package. If however, you do expect to only get APNs when running, then you do have a chance to do application specific actions.

Noting - you also have the issue of the user's language. You've currently selected English for "Your driver ..."

The typical approach is to record the user's timezone and language (and other locale information) on your server, usually at the time of registration. Then, when your server generates the APN it customizes it for the user's locale.

GoZoner
  • 67,920
  • 20
  • 95
  • 145
  • I've been thinking about this, and it works for the general case, but how would you solve this for edge cases like Arizona that don't observe DST? Looking through the NSTimeZone API's, I am having a hard time fitting that one together. – kcharwood Aug 20 '14 at 21:32
0

No, there's no way to turn that message.

I think you should get the timezone permanently at your server.

Oh Seung Kwon
  • 431
  • 3
  • 11