Multi application support

178 views
Skip to first unread message

kennini

unread,
Mar 27, 2010, 8:31:17 AM3/27/10
to Easy APNs
Hello everyone,

I'm wondering if Easy APNs can handle more than one app ID.
As I understand from the Apple documentation, a new certificate must
be generated for each unique appID.

I can't find where I can put more than one certificate set (prod and
sandbox) in Easy APNs configuration.

Thanks for your help.

The Toad

unread,
Mar 30, 2010, 8:44:11 AM3/30/10
to Easy APNs
No answer here? I'm having the same issue.

Manifest Interactive

unread,
Mar 30, 2010, 9:13:45 AM3/30/10
to easy...@googlegroups.com
That's what I get for only having one app running using this code...

I have updated the class_APNS.php file to you can pass the new
certificates as part of the constructor.

So if you are like me and only have one app, you do not need to pass
anything new and your old code will still work, but if you need to use
alt certificates, now you can with ease ;)

New code looks something like this...

<code>
<?php
$db = new DbConnect();
$db->show_errors();
$apns = new APNS($db, NULL, '/usr/local/apns/alt_apns.pem',
'/usr/local/apns/alt_apns-dev.pem');
?>
</code>

Source code is here...

http://code.google.com/p/easyapns/source/browse/trunk/src/php/classes/class_APNS.php

Raw File is here...

http://easyapns.googlecode.com/svn/trunk/src/php/classes/class_APNS.php

Will also make a new download once you guys tell me that it works as expected.

Thanks,

- Peter

> --
> You received this message because you are subscribed to the Google
> Groups "Easy APNS" group.
> To post to this group, send email to easy...@googlegroups.com
> To unsubscribe from this group, send email to
> easyapns+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/easyapns?hl=en
>
> To unsubscribe from this group, send email to easyapns+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
>

Hutch Hicken

unread,
Mar 30, 2010, 9:35:59 AM3/30/10
to easy...@googlegroups.com
This mean that I would have to handle the hashing of Application Name to prod/dev key before invoking the class. Doesn't it make more sense to create a new apns_certificates table with appname as the key and a field for the path of the certficates? Then the class itself can find the right key based on the app name passed by the iP* Apps. For backward compatibility, we could make the database lookup conditional on a zero-length $certificate variable. If the $certificate or $sandboxCertificate variables are filled, we'll skip the db lookup. What do you think?

Manifest Interactive

unread,
Mar 30, 2010, 9:40:49 AM3/30/10
to easy...@googlegroups.com
It seems logical that for users with multiple applications, their PHP
code that will be instantiating the APNS class object will already
contain some sort of logic as to which app they are looking for.

The existing application already records each user and which app they
are tied to.

So to send a message to a user they would need to fetch them by
application anyway, so to me, at least, it seems that this is where
the developer could put in a switch statement or some other logic to
pass over the correct certificate paths to the APNs object.

I would love to hear some more opinions on this.

- Peter Schmalfeldt

kennini

unread,
Apr 2, 2010, 4:25:23 AM4/2/10
to Easy APNs
Thanks for the quick fix !
I will test it and let you you if it's working

Ken

On Mar 30, 3:13 pm, Manifest Interactive


<manifestinteract...@gmail.com> wrote:
> That's what I get for only having one app running using this code...
>
> I have updated the class_APNS.php file to you can pass the new
> certificates as part of the constructor.
>
> So if you are like me and only have one app, you do not need to pass
> anything new and your old code will still work, but if you need to use
> alt certificates, now you can with ease ;)
>
> New code looks something like this...
>
> <code>
> <?php
> $db = new DbConnect();
> $db->show_errors();
> $apns = new APNS($db, NULL, '/usr/local/apns/alt_apns.pem',
> '/usr/local/apns/alt_apns-dev.pem');
> ?>
> </code>
>
> Source code is here...
>

> http://code.google.com/p/easyapns/source/browse/trunk/src/php/classes...

rcbowser

unread,
Apr 6, 2010, 12:42:02 AM4/6/10
to Easy APNs
I'm not expert with either PHP or MySql, but I used easy APN to set up
push for multi applications for a friend of mine.
What I did was use a switch statement in the PHP code and added more
to the tables.

This is not pretty but it works great.
By using the app name and only pointing the the directory where the
cert live as a value I then append the name of the cert to the path.
I also set it up to be a sandbox application or production.

$appname = $this->db->prepare($appname);
$appversion = $this->db->prepare($appversion);
$deviceuid = $this->db->prepare($deviceuid);
$devicetoken = $this->db->prepare($devicetoken);
$devicename = $this->db->prepare($devicename);
$devicemodel = $this->db->prepare($devicemodel);
$deviceversion = $this->db->prepare($deviceversion);
$pushbadge = $this->db->prepare($pushbadge);
$pushalert = $this->db->prepare($pushalert);
$pushsound = $this->db->prepare($pushsound);

// set up case for cert name for each app and current production
status.
switch ($appname){

case "iLaunderette":
//$certname ='iLaunderetteProdKey.pem';
$certname = 'iLaunderettDev.pem';
$development = 'production';
break;
case "feedthemeter":
$certname = 'feedthemeterDev.pem';
$development = 'production';
$break;
default:
echo "Bring lots of underwear!"; // found this on the web looking
for switch examples.. Love it!
break;

Reply all
Reply to author
Forward
0 new messages