Code Monkey home page Code Monkey logo

apn's Introduction

Laravel APN (Apple Push) Notification Channel

Work in Progress

Here's the latest documentation on Laravel 5.3 Notifications System:

https://laravel.com/docs/master/notifications

A Boilerplate repo for contributions

Latest Version on Packagist Software License Build Status StyleCI SensioLabsInsight Quality Score Code Coverage Total Downloads

This package makes it easy to send notifications using Apple Push (APN) with Laravel 5.3.

Contents

Installation

Install this package with Composer:

composer require laravel-notification-channels/apn

Register the ServiceProvider in your config/app.php:

NotificationChannels\Apn\ApnServiceProvider::class,

Setting up the APN service

Before using the APN Service, follow the Provisioning and Development guide from Apple

You will need to generate a certificate for you application, before you can use this channel. Configure the path in config/broadcasting.php

    'connections' => [
      ....
      'apn' => [
          'environment' => ApnChannel::PRODUCTION, // Or ApnChannel::SANDBOX
          'certificate' => '/path/to/certificate', 
          'pass_phrase' => null, // Optional passPhrase
      ],
      ...
    ]

Usage

You can now send messages to GCM by creating a GcmMessage:

use NotificationChannels\Apn\ApnChannel;
use NotificationChannels\Apn\ApnMessage;
use Illuminate\Notifications\Notification;

class AccountApproved extends Notification
{
    public function via($notifiable)
    {
        return [ApnChannel::class];
    }

    public function toApnNotification($notifiable)
    {
        return ApnMessage::create()
            ->badge(1)
            ->title('Account approved')
            ->body("Your {$notifiable->service} account was approved!");
    }
}

In your notifiable model, make sure to include a routeNotificationForApn() method, which return one or an array of tokens.

public function routeNotificationForApn()
{
    return $this->apn_token;
}

Available methods

  • title($str)
  • body($str)
  • badge($integer)
  • custom($customData)

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

apn's People

Contributors

techguard avatar freekmurze avatar barryvdh avatar elfsundae avatar lucadegasperi avatar

Watchers

James Cloos 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.