Giter Club home page Giter Club logo

php-push-notification-server's Introduction

Push sender

Connection through TCP/IP sockets

config.json

{
  "ip": "",
  "port": 10000,
  "jwtToken": "kjdsfhjk849678946",
  "apns": {
    "all": {
      "key": "certificates/AuthKey_FHH747JJD.p8",
      "keyPassword": "",
      "keyId": "FHH747JJD",
      "teamId": "SERTYUJJ",
      "production": false
    }
  },
  "gcm": {
    "all": {
      "apiKey": "AIzJdurHh377f7O95u-OAS_KKdfhh57878L4QcQ",
      "retries": 0
    },
    "byPattern": {
      "apiKey": "AJSGHdshjd8Hhhjf7O95u-OAS_KKdfhh57878L4QcQ",
      "retries": 10
    }
  },
  "map": {
    "apns": {
      "*": "corp"
    },
    "gcm": {
      "*": "all",
      "*pattern*": "byPattern"
    }
  }
}

message

\JWT::encode([
    'tokens'      => [
	    'dasasd8962ghgre'
    ],
    'bundleId'    => 'ru.test.baundle',
    'message'     => 'Service is ready',
    'title'       => 'Hello, guys!',
    'sound'       => null,
    'extraParams' => [
	    'acme' => ''
    ],
], $this->getJwtKey());

response

[
   {
      "token":"dasasd8962ghgre",
      "statusCode":400,
      "message":"DeviceTokenNotForTopic\nThe device token does not match the specified topic"
   }
]

Example

sudo docker run -d -i --name pusher -p 10000:10000 -v /home/www-docker/builds/build-pusher-1/certificates:/usr/src/pusher/certificates -v /home/www-docker/builds/build-pusher-1/config.json:/usr/src/pusher/config.json professionalweb/push-notification-server
/* Create  TCP/IP socket. */
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if ($socket === false) {
    $m = "Can't create socket through socket_create(): couse: " . socket_strerror(socket_last_error());
    \Log::error($m);
    throw new \Exception($m);
}

$result = socket_connect($socket, $this->getPushServiceIp(), $this->getPushServicePort());
if ($result === false) {
    $m = "Can't execute socket_connect().\nCause: ($result) " . socket_strerror(socket_last_error($socket)) . "\n";
    \Log::error($m);
    throw new \Exception($m);
}

$message = \JWT::encode([
           'platform'    => 'android',
           'tokens'      => ['dasdw534535'],
           'bundleId'    => 'ru.bundle.name',
           'message'     => 'Have a nice day!',
           'title'       => 'Hello',
           'sound'       => '',
           'extraParams' => [
                'acme' => 'Some param'
           ],
       ], '<JWT-KEY>')
socket_write($socket, $message, strlen($message));
$message = "\n";
socket_write($socket, $message, strlen($message));

$response = socket_read($socket, 2048);

socket_close($socket);

php-push-notification-server's People

Contributors

sergiomadness avatar

Watchers

 avatar  avatar  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.