1

The Push Notification plugin will send out alerts ONLY if devMode is set to true.

I can't leave my production environment in development mode so I'm trying to figure out why the alerts won't send when devMode is set to false.

I have checked the PushNotifications_PushService.php page and the logs will print out that Notified is 1 (which would be correct for my test). However, the alert never sends out. My phone never receives the alert.

My only assumption is that it deals with the APNSAdapter but that is coming from Sly/NotificationPusher. I've never worked with this class before so I'm not sure exactly how it works. Does anyone have any ideas what is going on?

UPDATE 1:

I am pretty sure the problem deals with the NotificationPusher class that the developer is importing. However, I'm not sure what is wrong with it.

See this: https://stackoverflow.com/questions/27611388/phonegap-pushplugin-with-notificationpusher-not-working-in-production

Here is an issue also posted on the NotificationPusher GitHub: https://github.com/Ph3nol/NotificationPusher/issues/111

UPDATE 2:

Tested via command line using the following command: ./np push --certificate=/path/to/production_ck.pem apns deviceToken "Notification test"

This worked. No errors. Phone received alert.

Still not sure why it won't receive them from Plugin in Production Mode.

UPDATE 3:

I have placed log statements into the NotificationPusher class. I found no errors when comparing it to the "Dev" process.

I noticed when debugging the NotificationPusher project that it utilizes zendframework APNS to send the messages. My assumption is that the error must be somewhere within this project.

I found this: http://framework.zend.com/manual/1.12/en/zend.mobile.push.apns.html

In the first comment, he isn't getting any errors either but the alert is never getting to the device.

As far as the NotificationPusher project, I was able to determine that:

  1. It is getting the device token and the message data
  2. The response data is the same for both development mode and production mode. (However, the iPhone device never receives the alert message in production mode.) Still no error from code

Has anyone worked with the Zendframework? Any ideas what is going on?

UPDATE 4:

The only difference I have found so far is that the development mode uses the sandbox URL whereas the production mode uses the production mode.

What doesn't make sense is that I'm using my production certificate and it works on the sandbox URL but it doesn't work on the production URL.

2
  • Is your app compiled in Xcode to use production URLs? Commented May 9, 2016 at 18:39
  • Yes. The URLs are correct. I'm beginning to think something is up with the certificates. It's very weird but my production certificate is working with the Sandbox URL. I do not know why. This makes no sense to me.
    – Sandy D.
    Commented May 9, 2016 at 18:43

1 Answer 1

2

I finally figured this out!

For any iOS application, in order to test the "Production" alerts to a physical iPhone Device -> You have to create an Ad-Hoc Application and deploy that to your iPhone device.

In order to do this, you must have an Ad-Hoc Distribution Profile created in the Member Center of "Certificates, Identifiers, and Profiles.

See this page for more information: https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/TestingYouriOSApp/TestingYouriOSApp.html

When using the Push Notification Plugin in debug mode, it works with the sandbox URL of Apple's Push Alerts. It will not use the production URL if you have debugMode set to true in the general.php file of Craft's configs.

Note: You will also have to set up the production certificate and configure that in the Push Notification Plugin settings to use the PEM file for the Production.

Once you deploy an Ad-Hoc Application to your iPhone device and have the PEM file setting pointed to your Production certificate, then everything should work fine (Make sure debugMode is set to false or remove this setting from the general.php file), the device will receive the alert.

I have tested this and it works on my iPhone 6 device.

Nothing is wrong with the ZendFramework or Push Notification code.

The issue was the deployment for the application on the iPhone device. I was testing directly from Xcode and using its build which is a development build (not an Ad-Hoc Build).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.