Пример #1
0
function send_notifications($title, $message, $id, $url)
{
    Log::info('push notification');
    $devices = MobileRegister::all();
    foreach ($devices as $device) {
        if ($device->device_type == 'ios') {
            /* WARNING:- you can't pass devicetoken as string in GCM or IOS push
             * you have to pass array of devicetoken even thow it's only one device's token. */
            /* send_ios_push("E146C7DCCA5EBD49803278B3EE0C1825EF0FA6D6F0B1632A19F783CB02B2617B",$title,$message,$type); */
            //send_ios_push($device->gcm, $title, $message);
        } else {
            //$message = json_encode($message);
            send_android_push($device->gcm, $title, $message, $id, $url);
        }
    }
}
Пример #2
0
function send_notifications($id, $type, $title, $message, $is_imp = NULL)
{
    Log::info('push notification');
    $settings = Settings::where('key', 'push_notification')->first();
    $push_notification = $settings->value;
    if ($type == 'walker') {
        $user = Walker::find($id);
    } else {
        $user = Owner::find($id);
    }
    if ($push_notification == 1 || $is_imp == "imp") {
        if ($user->device_type == 'ios') {
            /* WARNING:- you can't pass devicetoken as string in GCM or IOS push
             * you have to pass array of devicetoken even thow it's only one device's token. */
            /* send_ios_push("E146C7DCCA5EBD49803278B3EE0C1825EF0FA6D6F0B1632A19F783CB02B2617B",$title,$message,$type); */
            send_ios_push($user->device_token, $title, $message, $type);
        } else {
            $message = json_encode($message);
            send_android_push($user->device_token, $title, $message);
        }
    }
}