我目前使用OneSignal作为网络推提供商,并想独立消息发送给我的所有用户不依赖,依靠他们的服务(显然,新引进的成本)。
OneSignal不要让我下载我的整个用户数据库,包括GCM / FCM数据。
在数据提供了足够的写一个简单的代码,将消息发送到从所述数据库中的用户?
下面是一排,与他们所提供的字段的例子:
id
identifier
session_count
language
timezone
game_version
device_os
device_type
device_model
ad_id tags
last_active
playtime
amount_spent
created_at
invalid_identifier
badge_count
lat
lon
rooted
ip
country web_auth
web_p256
7a2ad79c-4315-4b57-be2b-6cce179260ed
https://android.googleapis.com/gcm/send/eNKyRHWMfMs:APA91bHMRVQk7gz27_JNTEsMnorqzd_JR6626eg43p-BhXmb1pslLX66db6w5-Aj--3GtpoCSVRHzMv2y_9tQlIVWKLakfmfLEAXy3rOsI4dvujHwou_X2wY9-TezBuDgST-o5A0fvo3
1
en
28800
56.0
5
Win32 Chrome
{}
2017-03-11 13:48:03.503015
0
0.00
2017-03-11 13:48:03.488008
t
0
f
125.60.243.173
PH
BFgB3OnEz3fGbNEbC/hiMA==
BMgmk8uppenwp1c5sPprEPHNYOu7n8yUjbAU7sKaImqldN+WnJosdZmUV/d4bv7RyQYiqu/z6KsJSn99B+A3IIA=
如果有可能,我将极大地欣赏正在一个代码示例的方向送出,在任何语言(优选PHP,不一定),即可以完成将消息发送到该用户,例如,
谢谢!
您可以使用一个信号的REST API将通知发送给用户。一个信号发送的卷曲要求符合要求的所有细节 -
$content = array(
"en" => '' // Your message content
);
$heading = array(
"en" => '' // Put heading according to you
);
$fields = array(
'app_id' => , // Enter our app id here
'filters' => array( array( "field" => "tag", "key" => "ad_id", "relation" => "=", "value" => 0) ), // You can use the ad_id data tag
"url" => '', // Enter your landing url
'contents' => $content,
'headings' => $heading
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json; charset=utf-8',
'Authorization: Basic '.REST_API_KEY.'' // Your api key
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$response = curl_exec($ch);
curl_close($ch);
return $response;
您可以使用数据标签或玩家ID在有关通知发送到过滤的用户。