Giter VIP home page Giter VIP logo

ionic-push-notifications's Introduction

Ionic Push Notifications Channel for Laravel

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

This package makes it easy to send Ionic Push Notifications with Laravel.

Content

Installation

You can install the package via composer:

composer require laravel-notification-channels/ionic-push-notifications

Setting up the Ionic Push service

Add your Ionic Push Authentication Token to your config/services.php:

// config/services.php
'ionicpush' => [
    'key' => env('IONIC_PUSH_API_KEY'),
]

Usage

Now you can use the channel in your via() method inside the notification:

use NotificationChannels\IonicPushNotifications\IonicPushChannel;
use NotificationChannels\IonicPushNotifications\IonicPushMessage;
use Illuminate\Notifications\Notification;

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

    public function toIonicPush($notifiable)
    {
        return IonicPushMessage::create('my-security-profile')
            ->title('Your title')
            ->message('Your message')
            ->sound('ping.aiff')
            ->payload(['foo' => 'bar']);
    }
}

You can easily set different settings for iOS and Android individually like this...

use NotificationChannels\IonicPushNotifications\IonicPushChannel;
use NotificationChannels\IonicPushNotifications\IonicPushMessage;
use Illuminate\Notifications\Notification;

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

    public function toIonicPush($notifiable)
    {
        return IonicPushMessage::create('my-security-profile')
            ->iosMessage('Your iOS message')
            ->androidMessage('Your Android message')
            ->iosSound('ping.aiff')
            ->androidSound('ping.aiff');
    }
}

In order to let your Notification know which device token to send to, add the routeNotificationForIonicPush method to your Notifiable model.

This method needs to return the device token of the user (or the Ionic Auth email address, or Ionic userID of the user). Do not forget to set the method of targeting users with sendTo() if necessary (see below).

public function routeNotificationForIonicPush()
{
    return $this->device_token;
}

You can also return multiple tokens to send to a group of devices the user may own

public function routeNotificationForIonicPush()
{
    return $this->device_tokens;
}

Available Message methods

  • create(): Accepts a string value of your-security-profile.
  • title(): The title of your notification (for all platforms). Can be overwritten by platform specific title method (see below).
  • message(): The message content of your notification (for all platforms). Can be overwritten by platform specific message method (see below).
  • sound(): The title of your notification (for all platforms). Can be overwritten by platform specific sound method (see below).
  • payload(): An array of data to send with your notification. Can be overwritten by platform specific payload method (see below).
  • scheduled(): Schedule a notification for future delivery. Accept DateTime object or a date as a string.
  • sendTo(): Set the method of targeting users - tokens (default), user_ids, or emails.

iOS specific methods

See here for full details on these methods.

  • iosMessage()
  • iosTitle()
  • iosBadge()
  • iosPayload()
  • iosSound()
  • iosPriority()
  • iosExpire()
  • iosContentAvailable()

Android specific methods

See here for full details on these methods.

  • androidCollapseKey()
  • androidContentAvailable()
  • androidData()
  • androidDelayWhileIdle()
  • androidIcon()
  • androidIconColor()
  • androidMessage()
  • androidPriority()
  • androidSound()
  • androidTag()
  • androidTimeToLive()
  • androidTitle()

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.

ionic-push-notifications's People

Contributors

jaybizzle avatar freekmurze avatar pavoltanuska avatar bfgasparin avatar mtpultz avatar fureszk 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.