Is an app required? #3

Closed
michaelkirk opened this Issue Oct 26, 2010 · 8 comments

Projects

None yet

5 participants

The old version of apn_on_rails had no concept of apps. It was assumed you only had one set of certificates.

This new (and improved!) version lets you group devices by app; however, it's not clear if it's required.

If you only have one app, do you still need to define that app in the databse, or can you use apn_on_rails in a way backwards compatible with markbates' version?

M

Member

The way that certificates are stored with the application has changed fundamentally. We are talking about adding the ability to use the old-style APIs and treat your application as a single-app, but for right now this is not possible with the latest version.

Almost every change made to the gem for the latest version was to allow multiple apps, so if you are dealing with a single app, you might consider using the last version.

I will be leaving this issue open for consideration in the next release.

Is there an upgrade path to convert from the previous setup to new setup -- or is just "manually create an app record with your keys"?

I'm not that familiar with the code, but I think it is a manual process. You'll have to create an app with your keys, and associate all the old devices with your new app.

Jirapong commented Nov 8, 2010

ruby script/console

> a = APN::App.new
> a.apn_dev_cert = File.read('......_push.pem')
> a.save

hope this help

Member

The above comments correctly show how to create an app. But in order to make the app compatible with existing implementations without code changes the current version (0.4.1) now allows devices not associated with an APN::App and uses the certs stored in the config directory to send notifications addressed to those apps.

Thanks for the feedback leading to this change.

It appears that notifications are now sent via rake task, rather than as they are created - but with the fix to allow "single app" code, there are no App records for the rake task to find, and thus there are no notifications sent?

Member

Hi,

The notifications can be sent by calling a method or by calling a rake task that calls a method. This has not changed in this version or in the 4.0 update. They are, as you note, not sent when they are created.

The APN::App.send_notifications method will send all unsent notifications for any APN::Apps and also any unsent notifications that are not associated with an APN::App. So even if you have not created any APN::App instances, you should call the APN::App class method to send your notifications. The old method that I deprecated (I think it is APN::Notification.send_notifications or something like that) prints a deprecation message but also calls the APN::App.send_notifications method so even if you don't change from old code that calls the deprecated method your notifications should still send.

I can't tell from your message whether you are finding that your notifications are not being sent when you call APN::App.send_notifications. I tested it out in the context of a larger Rails app using both devices/notifications not associated with an APN::App instance and ones that were. I was able to send the notifications in both cases. But of course there is always the possibility of a bug!

Thanks,
Rebecca

Yeah...just noticed that. I think I actually have an issue with ssl certs in my app. I'll report back here if I can't get it to work, but I see no reason why it won't work like you just described, now that I check out the code.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment