Example #1
0
/**
 * Created by PhpStorm.
 * User: jiulu
 * Date: 2015/12/23
 * Time: 21:58
 * @param $uid
 * @param $title
 * @param $text
 * @return bool
 */
function sendDeviceUnicast($uid, $ticker, $title, $text)
{
    if (empty($uid) || $title == '' || $text == '') {
        err_ret(-205, 'lack of param', '缺少参数');
    }
    $model = new Model('apns_user');
    $condition['uid'] = $uid;
    $result = $model->where($condition)->select();
    if (count($result) <= 0) {
        return false;
    }
    $type = $result[0]['type'];
    $device_token = $result[0]['device_token'];
    if ($type == 1) {
        //安卓设备
        Vendor('UmengPushAPI.UmengPushAPI');
        $umengPush = new \UmengPushAPI();
        $umengPush->sendAndroidUnicast($device_token, $ticker, $title, $text);
    } else {
        if ($type == 2) {
            //苹果设备
        }
    }
}
Example #2
0
            $customizedcast->setPredefinedKeyValue("alias", "xx");
            // Set your alias_type here
            $customizedcast->setPredefinedKeyValue("alias_type", "xx");
            $customizedcast->setPredefinedKeyValue("alert", "IOS 个性化测试");
            $customizedcast->setPredefinedKeyValue("badge", 0);
            $customizedcast->setPredefinedKeyValue("sound", "chime");
            // Set 'production_mode' to 'true' if your app is under production mode
            $customizedcast->setPredefinedKeyValue("production_mode", "false");
            print "Sending customizedcast notification, please wait...\r\n";
            $customizedcast->send();
            print "Sent SUCCESS\r\n";
        } catch (Exception $e) {
            print "Caught exception: " . $e->getMessage();
        }
    }
}
// Set your appkey and master secret here
$umengPushApi = new UmengPushAPI("your appkey", "your app master secret");
$umengPushApi->sendAndroidUnicast();
/* these methods are all available, just fill in some fields and do the test
 * $umengPushApi->sendAndroidBroadcast();
 * $umengPushApi->sendAndroidFilecast();
 * $umengPushApi->sendAndroidGroupcast();
 * $umengPushApi->sendAndroidCustomizedcast();
 *
 * $umengPushApi->sendIOSBroadcast();
 * $umengPushApi->sendIOSUnicast();
 * $umengPushApi->sendIOSFilecast();
 * $umengPushApi->sendIOSGroupcast();
 * $umengPushApi->sendIOSCustomizedcast();
 */