Closed (fixed)
Project:
Push Notifications
Version:
7.x-1.0-beta2
Component:
User interface
Priority:
Normal
Category:
Support request
Assigned:
Reporter:
Created:
25 Sep 2012 at 16:15 UTC
Updated:
30 Dec 2012 at 21:10 UTC
Now this may not be a problem with the module but hopefully you'll be able to advise as to what it wrong.
I did have this working a couple of weeks ago but it seems to have stopped working now and I'm not sure where the problem lies. As far as I can tell my app code is correct and the device is registered. Also I'm not getting errors when sending the notification, but the device is not receiving any notification
Therefore I can only think maybe it is a problem with my app or a problem with the certificates. Any suggestions would be welcome as I'm a bit stuck.
Comments
Comment #1
haagendazs commentedHey there. I'll be honest: that's a tough one, as there are some many places where it could fail. Here are a couple of ideas:
Comment #2
marcus178 commentedOk I found an example for send push notification here using php
http://lessons.runrev.com/m/4069/l/53405
and using the same certificate I'm using with this module, the php script sends the notification to my app ok.
The only think I can think of is I did switch the module to production at one point but then switched back to development when I found it did not work.
Comment #3
haagendazs commentedHi there: That page contains pretty much the code that this module is using as well. Without knowing your exact configuration, I'm sorry to say that I won't be able to figure out what the problem is.
Comment #4
marcus178 commentedWhat would you need to know? The site it's running on is pretty much a clean installation and I have tried the php script on the same server.
Comment #5
haagendazs commentedIf you named the certificates correctly, if they are in the correct location, if you're getting any errors in your log, if your token is stored in the database ...
Comment #6
marcus178 commentedThe certificate is name apns-development.pem and stored in push_notifications/certificates and my token is in the database. There are no error in my log.
Comment #7
marcus178 commentedUninstalling and reinstalling the module seems to have fixed it.
Comment #8
marcus178 commentedOk I have figured out what is wrong so hoping you might be able to shed some light on it.
The problem only occurs if there is more than one token in the database, so if I delete all the tokens apart the device I'm testing with it works. This is why when I did my initial testing it was just to one device and hence why it worked, after a few more devices got added it stopped working.
This problem does not occur for android, I have a couple of devices and they both receive the notifications.
Comment #9
vikom commentedHi! I can confirm the bug. When more than one device token is stored in the database the push notifications don't work.
Did any of you guys started working on a solution?
Comment #10
marcus178 commentedI glad someone else is experiencing the same issue as thought it was just me and I'd done something wrong. It's seems odd that it only affects ios and not android. Is there any update on what could be causing this.
Comment #11
marcus178 commentedOk I have done some research and sounds like just one connection should be opened and then all the message sent but it looks like at the moment a connection is created for each token. i.e $apns = push_notifications_open_apns(); is in foreach
so if I change to the below it works but not sure if that is exactly right
Comment #12
vikom commentedThanks @marcus178!
First I thought it had something to do with the development certificate I was using. I will try your fix and see if it works for me too.
I can also add to the bug report that everything looks fine when dumping variables. I get the success response for all tokens but only the first receives a push.
Comment #13
haagendazs commented@Vikom and marcus178: The suggested code change in #11 basically removes the re-generation of a stream context during the batch process, i.e. all push notifications are being sent out using one stream.
When I was creating this module, I wasn't able to find a clear answer on how many messages can be sent out through a single stream context. If you look at the configuration under /admin/config/services/push_notifications/configure, there is a setting for it called "Stream Context Limit". Instead of changing the code, you can also change the "Stream Context Limit" to 1 and achieve the same result, i.e. creating a new stream context for every notification that should be sent out.
Could you play around with that setting and see if that has any effect on the delivery on the notifications? I looked at the example in the URL from comment #2 (http://lessons.runrev.com/m/4069/l/53405). That example only describes the delivery of a single message, so they don't really have to deal with the batch-delivery.
Basically: could you try setting your Stream Context Limit to different values (try a really low value (1) and a really high value (50) without using the above code change) and let me know if that has any effects on delivery?
Comment #14
vikom commentedOK, so I tested this now. Setting the "Stream Context Limit" to 1 will work for multiple devices. Any of the settings above 1 will only send to the first token in the db.
Thank you!
Comment #15
haagendazs commentedThanks a lot for the feedback. I'll change the default value in the next version I'll release for this module to "1" for the stream context limit and add a stronger warning that it might not work with higher values. I promise that it has been and still is working with more than 1 message per stream, I'm sending about 3-5 with the same code.
Comment #16
haagendazs commented