<?php
defined('BASEPATH') OR exit('No direct script access allowed');


/**
 * Voucher Class
 *
 * @package     Edusol
 * @subpackage  Fee
 * @author      Usama Ali 
 * @link        http://facebook.com/sabeehking
 */

class Api_model extends CI_Model {

    public function __construct()
    {
        parent::__construct();
        $this->load->database();
    }




function send_notification($tokens, $message){
    
	$url = 'http://fcm.googleapis.com/fcm/send';

 //var_dump($message);
 //die();

	$fields = array(
		'registration_ids' => $tokens,
		'data' => $message
		);
		
//var_dump($fields);
 //die();

	$headers = array(
		'Authorization:key = AIzaSyDiN45DvCXk8d2WvwsG7JTDSH17Yv1P-I0',
		'Content-Type: application/json');

	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_POST, true);
	curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
	curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));

	$result = curl_exec($ch);
        if($result === FALSE){
		die('Curl Failed' . curl_error($ch));
	}
	curl_close($ch);

	return $result;

}

}
