【发布时间】:2015-08-19 23:33:15
【问题描述】:
我已经按照所有步骤从here 开始在离子框架中构建简单的应用程序。我正在使用服务器端的php 代码来调用离子API for push notification。我使用了以下代码,但在我的应用程序中没有收到通知,请提出解决方案。
<?php
$androidAppId = "e2c77770";
$data = array(
"tokens" => "APA91bF2YePDKxE6K6vZYs2KQ27Z4mdehJg-EaZaPy10w-RHN5RUgC_P6Uie24Qu_M28j9bfZcbU6pu8Awofa8h2G5j9jABnebrVIUgKM5JcZPEJHYVW2NINirAm7VnSqGOrqm4YicAoI9Xiw5zkgTx4edqXIANLEhvqsqSCeq-_gAuzZB8wvrQ",
"notification" => "Hello World!"
);
$data_string = json_encode($data);
$ch = curl_init('https://push.ionic.io/api/v1/push');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'X-Ionic-Application-Id: '.$androidAppId,
'Content-Length: ' . strlen($data_string))
);
$result = curl_exec($ch);
?>
【问题讨论】:
标签: php android ionic-framework ionic