mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
iOS Push Notifications
This commit is contained in:
parent
6558bfcce9
commit
50ddbcf609
@ -552,6 +552,9 @@ if (!defined('CONTACT_EMAIL')) {
|
||||
define('TEST_PASSWORD', 'password');
|
||||
define('API_SECRET', 'API_SECRET');
|
||||
|
||||
define('IOS_PRODUCTION_PUSH','ninjaIOS');
|
||||
define('IOS_DEV_PUSH','devNinjaIOS');
|
||||
|
||||
define('TOKEN_BILLING_DISABLED', 1);
|
||||
define('TOKEN_BILLING_OPT_IN', 2);
|
||||
define('TOKEN_BILLING_OPT_OUT', 3);
|
||||
|
89
app/Ninja/Notifications/PushFactory.php
Normal file
89
app/Ninja/Notifications/PushFactory.php
Normal file
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace App\Ninja\Notifications;
|
||||
|
||||
use Davibennun\LaravelPushNotification\Facades\PushNotification;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
* Class PushFactory
|
||||
* @package App\Ninja\Notifications
|
||||
*/
|
||||
|
||||
class PushFactory
|
||||
{
|
||||
/**
|
||||
* PushFactory constructor.
|
||||
*/
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->certificate = IOS_DEV_PUSH;
|
||||
}
|
||||
|
||||
/**
|
||||
* customMessage function
|
||||
*
|
||||
* Send a message with a nested custom payload to perform additional trickery within application
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param $token
|
||||
* @param $message
|
||||
* @param $messageArray
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function customMessage($token, $message, $messageArray)
|
||||
{
|
||||
$customMessage = PushNotification::Message($message, $messageArray);
|
||||
|
||||
$this->message($token, $customMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* message function
|
||||
*
|
||||
* Send a plain text only message to a single device.
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param $token - device token
|
||||
* @param $message - user specific message
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
|
||||
public function message($token, $message)
|
||||
{
|
||||
PushNotification::app($this->certificate)
|
||||
->to($token)
|
||||
->send($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* getFeedback function
|
||||
*
|
||||
* Returns an array of expired/invalid tokens to be removed from iOS PUSH notifications.
|
||||
*
|
||||
* We need to run this once ~ 24hrs
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param string $token - A valid token (can be any valid token)
|
||||
* @param string $message - Nil value for message
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getFeedback($token, $message = '')
|
||||
{
|
||||
|
||||
$feedback = PushNotification::app($this->certificate)
|
||||
->to($token)
|
||||
->send($message);
|
||||
|
||||
return $feedback->getFeedback();
|
||||
}
|
||||
|
||||
}
|
@ -10,6 +10,7 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"turbo124/laravel-push-notification": "dev-laravel5",
|
||||
"omnipay/mollie": "dev-master#22956c1a62a9662afa5f5d119723b413770ac525",
|
||||
"omnipay/2checkout": "dev-master#e9c079c2dde0d7ba461903b3b7bd5caf6dee1248",
|
||||
"omnipay/gocardless": "dev-master",
|
||||
|
816
composer.lock
generated
816
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -164,6 +164,7 @@ return [
|
||||
'App\Providers\RouteServiceProvider',
|
||||
|
||||
'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider',
|
||||
'Davibennun\LaravelPushNotification\LaravelPushNotificationServiceProvider',
|
||||
],
|
||||
|
||||
/*
|
||||
@ -249,6 +250,7 @@ return [
|
||||
'Rocketeer' => 'Rocketeer\Facades\Rocketeer',
|
||||
'Socialite' => 'Laravel\Socialite\Facades\Socialite',
|
||||
'Excel' => 'Maatwebsite\Excel\Facades\Excel',
|
||||
'PushNotification' => 'Davibennun\LaravelPushNotification\Facades\PushNotification',
|
||||
|
||||
],
|
||||
|
||||
|
23
config/push-notification.php
Normal file
23
config/push-notification.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
'devNinjaIOS' => array(
|
||||
'environment' =>'development',
|
||||
'certificate'=>app_path().'/certs/ninjaIOS.pem',
|
||||
'passPhrase' =>'',
|
||||
'service' =>'apns'
|
||||
),
|
||||
'ninjaIOS' => array(
|
||||
'environment' =>'production',
|
||||
'certificate'=>app_path().'/certs/productionNinjaIOS.pem',
|
||||
'passPhrase' =>'',
|
||||
'service' =>'apns'
|
||||
),
|
||||
'ninjaAndroid' => array(
|
||||
'environment' =>'production',
|
||||
'apiKey' =>'yourAPIKey',
|
||||
'service' =>'gcm'
|
||||
)
|
||||
|
||||
];
|
Loading…
x
Reference in New Issue
Block a user