1
A
回答
1
2
您必须使用需要付费方案的Remote Access API。 我创建一个包含我要发送的文字和设备令牌我想将它发送到并传递作为参数传递给下面的函数对象:
function push(object) {
var params = {
"request": {
"application": "PW_ID GOES HERE",
"auth": "Find in your API Access page",
"notifications": [{
// Content Settings
"send_date": "now",
"ignore_user_timezone": true,
"content": {
"en": object.text
},
"platforms": [1, 3], // 1 - iOS; 3 - Android;
// iOS Related
"ios_category_id": "1",
"ios_badges": "+1",
// Android Related
"android_icon": "icon",
// Who to send it to
"devices": object.tokens
}]
}
};
$http.post('https://cp.pushwoosh.com/json/1.3/createMessage', params).then(success, failure);
function success() {
console.log("successful notification push");
}
function failure(error) {
console.log('error sending notification', error);
}
}
0
这里是像我使用
- 发送请求到服务器
$http.get('http://test.com/push.php?token=' + ushToken + '&message=' + encodeURIComponent(message)).then(function (resp) {
}, function (err) {
console.error(err);
});
-
在服务器端
- 做
<?php
define('PW_AUTH', '...');
define('PW_APPLICATION', '...');
define('PW_DEBUG', FALSE);
function pwCall($method, $data)
{
\t $url = 'https://cp.pushwoosh.com/json/1.3/' . $method;
\t $request = json_encode(['request' => $data]);
\t $ch = curl_init($url);
\t curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
\t curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
\t curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
\t curl_setopt($ch, CURLOPT_HEADER, TRUE);
\t curl_setopt($ch, CURLOPT_POST, TRUE);
\t curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
\t $response = curl_exec($ch);
\t $info = curl_getinfo($ch);
\t curl_close($ch);
\t if (defined('PW_DEBUG') && PW_DEBUG) {
\t \t var_dump(json_decode($request));
\t \t var_dump($response);
\t \t var_dump($info);
\t }
}
if (isset($_GET['message']) && isset($_GET['token'])) {
\t $payload = [
\t \t 'application' => PW_APPLICATION,
\t \t 'auth' => PW_AUTH,
\t \t 'notifications' => [
\t \t \t [
\t \t \t \t 'send_date' => 'now',
\t \t \t \t 'content' => $_GET['message'],
\t \t \t \t 'devices' => [$_GET['token']]
\t \t \t ]
\t \t ]
\t ];
\t pwCall('createMessage', $payload);
}
相关问题
- 1. 科尔多瓦
- 2. 科尔多瓦 -
- 3. 科尔多瓦
- 4. INSTALL_FAILED_OLDER_SDK科尔多瓦
- 5. 科尔多瓦和PushWoosh - 与Android - 在状态栏
- 6. 如何让GCM科尔多瓦得到与科尔多瓦2.3
- 7. Twitter的API POST科尔多瓦/离子
- 8. 与科尔多瓦
- 9. 在科尔多瓦
- 10. 科尔多瓦:在
- 11. 科尔多瓦:如何关闭科尔多瓦的页面?
- 12. 在Phonegap /科尔多瓦使用Instagram API
- 13. 提取API和科尔多瓦
- 14. angularjs科尔多瓦应用使用科尔多瓦插件
- 15. 从科尔多瓦访问科尔多瓦功能InAppBrowser
- 16. 离子2科尔多瓦,安装科尔多瓦插件typings
- 17. 科尔多瓦赋予” ......科尔多瓦/ node_modules/Q/q.js:126:错误
- 18. 科尔多瓦,发出“科尔多瓦运行android”后
- 19. 科尔多瓦错误:科尔多瓦构建Android
- 20. HTTP GET科尔多瓦
- 21. sharekit的科尔多瓦2.2.0
- 22. 科尔多瓦的WebSocket
- 23. 在科尔多瓦的WebView
- 24. Facebook的Openfb科尔多瓦
- 25. 科尔多瓦(PhoneGap)科罗娜
- 26. pushwoosh错误无法识别的选择发送到实例科尔多瓦1.7.0
- 27. 科尔多瓦插件undefined
- 28. 科尔多瓦PushNotification问题
- 29. 在Ionic2和科尔多瓦
- 30. iOS8科尔多瓦问题
我已经成功建立家居科尔多瓦的Android,我的设备接收推送通知,当我从pushwoosh.com发送。我无法找到存储库中的任何示例代码插件的phonegap **发送**推送通知从客户端。我忽略了什么? – huahax 2014-10-09 11:58:43
您无法从客户端推送。客户端(设备)只能注册接收通知。 – 2014-10-09 14:12:42
我遇到了同样的问题,您是否找到了解决方案? – mcneela86 2014-11-17 11:11:25