Giter Club home page Giter Club logo

codeigniter-apns's Introduction

Codeigniter-apns (c) 2012, Anton Gorodezkiy

Это библиотека для codeigniter для взаимодействия с Apple Push Notifications Service Библиотека основана на коде APNS Copyright (c) 2010 Benjamin Ortuzar Seconde [email protected]

Пример базового использования (controller):

function send_notifications()
{
	$this->load->library('apn');
	$this->apn->payloadMethod = 'enhance'; // включите этот метод для отладки
	$this->apn->connectToPush();

	// добавление собственных переменных в notification
	$this->apn->setData(array( 'someKey' => true ));

	$send_result = $this->apn->sendMessage($device_token, 'Тестовое уведомление #1 (TIME:'.date('H:i:s').')', /*badge*/ 2, /*sound*/ 'default'  );
		
	if($send_result)
		log_message('debug','Отправлено успешно');
	else
		log_message('error',$this->apn->error);

	
	$this->apn->disconnectPush();
}

// для получения идентификаторов устройств, на которых приложение больше не установлено
public function apn_feedback()
{
	$this->load->library('apn');

	$unactive = $this->apn->getFeedbackTokens();
	
	if (!count($unactive))
	{
		log_message('info','Feedback: No devices found. Stopping.');
		return false;
	}
	
	foreach($unactive as $u)
	{
		$devices_tokens[] = $u['devtoken'];
	}

	/*
	print_r($unactive) -> Array ( [0] => Array ( [timestamp] => 1340270617 [length] => 32 [devtoken] => 002bdf9985984f0b774e78f256eb6e6c6e5c576d3a0c8f1fd8ef9eb2c4499cb4 ) ) 
	*/
}

Codeigniter-apns (c) 2012, Anton Gorodezkiy

This is codeigniter library to work with Apple Push Notifications Service It based on APNS Copyright (c) 2010 Benjamin Ortuzar Seconde [email protected]

Basic usage for pushing (controller):

function send_notifications()
{
	$this->load->library('apn');
	$this->apn->payloadMethod = 'enhance'; // you can turn on this method for debuggin purpose
	$this->apn->connectToPush();
	
	// adding custom variables to the notification
	$this->apn->setData(array( 'someKey' => true ));

	$send_result = $this->apn->sendMessage($device_token, 'Test notif #1 (TIME:'.date('H:i:s').')', /*badge*/ 2, /*sound*/ 'default'  );
		
	if($send_result)
		log_message('debug','Sending successful');
	else
		log_message('error',$this->apn->error);

	
	$this->apn->disconnectPush();
}

// designed for retreiving devices, on which app not installed anymore
public function apn_feedback()
{
	$this->load->library('apn');

	$unactive = $this->apn->getFeedbackTokens();
	
	if (!count($unactive))
	{
		log_message('info','Feedback: No devices found. Stopping.');
		return false;
	}
	
	foreach($unactive as $u)
	{
		$devices_tokens[] = $u['devtoken'];
	}

	/*
	print_r($unactive) -> Array ( [0] => Array ( [timestamp] => 1340270617 [length] => 32 [devtoken] => 002bdf9985984f0b774e78f256eb6e6c6e5c576d3a0c8f1fd8ef9eb2c4499cb4 ) ) 
	*/
}

codeigniter-apns's People

Contributors

antongorodezkiy avatar djensenius avatar larcho avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.