Install Redis 2.6 on Amazon EC2 Linux AMI or CentOS

1. Install Linux updates, set time zones, followed by GCC and Make

sudo yum -y update
sudo ln -sf /usr/share/zoneinfo/America/Indianapolis \
/etc/localtime
sudo yum -y install gcc make

2. Download, Untar and Make Redis 2.6

wget http://redis.googlecode.com/files/redis-2.6.0-rc3.tar.gz
tar xzf redis-2.6.0-rc3.tar.gz
cd redis-2.6.0-rc3
make

3. Create Directories and Copy Redis Files

sudo mkdir /etc/redis /var/lib/redis
sudo cp src/redis-server src/redis-cli /usr/local/bin
sudo cp redis.conf /etc/redis

4. Configure Redis.Conf

sudo nano /etc/redis/redis.conf
[..]
daemonize yes
[..]
[..]
bind 127.0.0.1
[..]
[..]
dir /var/lib/redis
[..]

5. Download init Script

wget https://raw.github.com/saxenap/install-redis-amazon-linux-centos/master/redis-server

6. Move and Configure Redis-Server

Note: The redis-server to be moved below is the one downloaded in 5 above.

sudo mv redis-server /etc/init.d
sudo chmod 755 /etc/init.d/redis-server
sudo nano /etc/init.d/redis-server
redis="/usr/local/bin/redis-server"

7. Auto-Enable Redis-Server

sudo chkconfig --add redis-server
sudo chkconfig --level 345 redis-server on

8. Start Redis Server

sudo service redis-server start


Source url :http://codingsteps.com/install-redis-2-6-on-amazon-ec2-linux-ami-or-centos/

push notifications

Node js:

This is an easy basic implementation  about apple push notification by using node-js .

please get the apple certificate as well as the password from ios developer.

please create the following files

push_lib.js

var join = require(‘path’).join, pfx = join(__dirname, ‘Certificates.p12‘);

/*!
* Create a new gateway agent
*/

var apnagent = require(‘apnagent’), agent = module.exports = new apnagent.Agent();

/*!
* Configure agent
*/

agent.set(‘pfx file’, pfx).set(“passphrase”,’password‘).enable(‘sandbox’);

/*!
* Error Mitigation
*/

agent.on(‘message:error’, function (err, msg) {
switch (err.name) {
// This error occurs when Apple reports an issue parsing the message.
case ‘GatewayNotificationError’:
console.log(‘[message:error] GatewayNotificationError: %s’, err.message);

// The err.code is the number that Apple reports.
// Example: 8 means the token supplied is invalid or not subscribed
// to notifications for your application.
if (err.code === 8) {
console.log(‘ > %s’, msg.device().toString());
// In production you should flag this token as invalid and not
// send any futher messages to it until you confirm validity
}

break;

// This happens when apnagent has a problem encoding the message for transfer
case ‘SerializationError’:
console.log(‘[message:error] SerializationError: %s’, err.message);
break;

// unlikely, but could occur if trying to send over a dead socket
default:
console.log(‘[message:error] other error: %s’, err.message);
break;
}
});

/*!
* Make the connection
*/

agent.connect(function (err) {
// gracefully handle auth problems
if (err && err.name === ‘GatewayAuthorizationError’) {
console.log(‘Authentication Error: %s’, err.message);
process.exit(1);
}

// handle any other err (not likely)
else if (err) {
throw err;
}

// it worked!
var env = agent.enabled(‘sandbox’)
? ‘sandbox’
: ‘production’;

console.log(‘apnagent [%s] gateway connected’, env);
});

 

push_test.js

var agent = require(‘./push_lib’);
/*!
* Send message
*/
module.exports = “yourdevice token”;
var x=module.exports;
agent.createMessage()
.device(x)
.alert(‘Custom variables’)
.set(‘id_1’, 12345)
.set(‘id_2’, ‘abcdef’)
.send();

 

Source url :https://blog.engineyard.com/2013/developing-ios-push-notifications-nodejs

 

 

 

Laravel 5:

This is an easy basic implementation  about apple push notification by laravel 5 .

please get the apple certificate as well as the password from ios developer.

Run the follwoing command in order to geenrate pem file:

openssl pkcs12 -in Certificates.p12 -out my_private_key.pem -nodes

create a function :

function testPushNotification(){
PushNotification::app(‘appNameIOS’)
->to(‘c9bccca836e2ddeb153b3205f937cc212dd2fab295dd3f21807289ba33cd2970’)
->send(‘Hello World, i`m a push message from Audiochimp’);
}

 

riute.php

Route::get(‘/push’, ‘ClientController@testPushNotification’);

when we run baseurl/push we can get the notifcation

 

source url :https://github.com/davibennun/laravel-push-notification