thinkphp+cordova+极光推送sdk+corethink实现非原生app的消息推送机制,ios需要走苹果的apns服务,所以需要开发者账号,安卓是tcp长连接。
thinkphp+cordova+极光推送sdk+corethink实现非原生app的消息推送机制,ios需要走苹果的apns服务,所以需要开发者账号,安卓是tcp长连接。where(array('uid' => $push_data['to_uid']))->getfield('token', true);
if ($addon_config['production']) {
$production = true;
} else {
$production = false;
}
if ($push_token_list) {
// 初始化
$client = new \jpush($addon_config['app_key'], $addon_config['master_secret']);
$result = null;
foreach ($push_token_list as $key => $push_token) {
if ($push_token) {
// 简单推送
$tmp = $client->push()
->setplatform('all')
->addregistrationid($push_token)
->setnotificationalert($push_data['title'])
->addandroidnotification($push_data['title'], $push_data['title'], 1, array(url => $push_data['url']))
->addiosnotification($push_data['title'], 'default', '+1', true, 'ios category', array(url => $push_data['url']))
->setoptions($sendno = null, $time_to_live = null, $override_msg_id = null, $apns_production = $production, $big_push_duration = null)
->send();
if ($tmp) {
$result[$key] = $tmp;
}
}
}
if ($result) {
return $result;
} else {
$this->error = '推送失败';
return false;
}
} else {
$this->error = '该用户无可推送设备';
return false;
}
} else {
$this->error = '插件关闭';
return false;
}
}
}
ad:真正免费,域名+虚机+企业邮箱=0元