You CANNOT test push notification on emulators. Please use real devices.
WPHC supports both free and pro version of Delite Studio's plugin for WP.
More details about the product: http://www.delitestudio.com/wordpress/push-notifications-for-wordpress/
Open your Wordpress admin page and install "Push Notifications for WordPress (Lite)" then activate it.
If you have not already done so, you'll need to set up a Google API project, to generate your senderID. Follow these steps to do so.
In this example, be sure and substitute your own senderID. Get your senderID by signing into to your Google dashboard.
The senderID is found at Overview->Dashboard->Project Number or https://developers.google.com/mobile/add and follow the steps to get Cloud messaging senderID and apiKey.
** Tip: ** The senderID is a 12 digit number
Go to Push Notifications > Settings
and check the following checkboxes:
- Basic Options > Send push notifications when a new post is published
- Basic Options > Android devices
- Send Push Notifications for > Posts
- Misc > In the Android notification payload add the message field
Then go to "Android Push Notifications (via GMC)" section and enter you Google API key.
Do not forget to save.
Go to Push Notifications > Settings
and check the following checkboxes:
- Basic Options > Send push notifications when a new post is published
- Basic Options > iOS devices
- Send Push Notifications for > Posts
Once you have got your .pem files upload them in the iOS Push Notifications
section
Change baseUrl
in config/config.cson
"cordova":
"pushNotifications":
"enabled": true
"baseUrl": "http://yourDomain.com/pnfw"
"android":
"senderID": ""
To make sure your web service works open http://yourDomain.com/pnfw/register/
in your browser. You should see that:
{
"error": "401",
"reason": "Unauthorized",
"detail": "Invalid HTTP method"
}
npm run android
# or
npm run ios
Open the console via Chrome dev tools chrome://inspect/#devices
and inspect your device.
If push notifications are enabled and you have properly generated a key from Google cloud you should have a log that look like this:
[pushNotifications] registered!
It means the device has been registered.
If an error happened you will have the following log:
[pushNotifications] register failed!
The register http request fails with this message: {error: "401", reason: "Unauthorized", detail: "Parameter oauth_consumer_key is missing"}
Why am I getting the errors {Unable to connect to tls://gateway.sandbox.push.apple.com:2195}
or {Unable to connect to tsl://gateway.push.apple.com:2195}
?
If the "enabled" checkbox on the push notif parameters (in app) is never on. It could mean that the following checkboxes are not checked. Please check at least category
to resolve the problem.