示例#1
0
function notification($xid, $type, $badge_count, $message, $payload = array())
{
    $result = array();
    if ($type == 'member') {
        $result = get_instance()->member_db_model->get_member_device($xid);
    } else {
        $result = get_instance()->seller_db_model->get_seller_device($xid);
    }
    if ($result) {
        foreach ($result as $key => $row) {
            if ($row['push_token']) {
                if (strtoupper($row['device']) == 'ANDROID') {
                    sendGCMMessage($xid, $row['push_token'], $row['gcm_service_key'], $message, $badge_count, $payload);
                } else {
                    sendAPNSMessage($xid, $row['push_token'], $message, (int) $badge_count, $payload);
                }
            }
        }
    }
}
示例#2
0
function sendPush($logins, $content)
{
    $ios_devs = array();
    $droid_devs = array();
    foreach ($logins as $login) {
        if ($login->push_token == NULL || strlen($login->push_token) < 10) {
            continue;
        }
        if ($login->push_type == 1) {
            $ios_devs[] = $login->push_token;
        } else {
            if ($login->push_type == 2) {
                $droid_devs[] = $login->push_token;
            }
        }
    }
    sendGCMMessage($droid_devs, $content);
    sendAPNMessage($ios_devs, $content);
}