Skip to content

Commit 0675e98

Browse files
committed
v0.0.1
1 parent 273abc8 commit 0675e98

File tree

16 files changed

+960
-411
lines changed

16 files changed

+960
-411
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: [agordn52]

.github/workflows/publish.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# .github/workflows/publish.yml
2+
name: Publish to pub.dev
3+
4+
on:
5+
push:
6+
tags:
7+
- 'v[0-9]+.[0-9]+.[0-9]+*' # tag-pattern on pub.dev: 'v'
8+
9+
# Publish using the reusable workflow from dart-lang.
10+
jobs:
11+
publish-package:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v3
17+
18+
- name: Set up Flutter
19+
uses: subosito/flutter-action@v2
20+
21+
- name: Get dependencies
22+
run: flutter pub get
23+
24+
- name: Analyze code
25+
run: flutter analyze
26+
27+
- name: Format code
28+
run: dart format --fix .
29+
30+
- name: Check publish warnings
31+
run: dart pub publish --dry-run
32+
33+
- name: Publish package
34+
uses: k-paxian/dart-package-publisher@v1.5.1
35+
with:
36+
credentialJson: ${{ secrets.CREDENTIAL_SECRET }}
37+
flutter: true
38+
skipTests: true
39+
40+
- name: Update nylo.dev
41+
uses: fjogeleit/http-request-action@v1
42+
with:
43+
url: 'https://nylo.dev/api/github/actions/laravel-notify-fcm/version'
44+
method: 'POST'
45+
customHeaders: '{"Content-Type": "application/json", "X-GH-API-KEY": "${{ secrets.NYLO_API_GH_SECRET }}"}'
46+
data: '{"version": "${{ github.ref_name }}"}'

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
## [0.0.1] - 01-04-2022
1+
## [0.0.1] - 2024-06-07
22

33
* Initial release.

LICENSE

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,21 @@
1-
TODO: Add your license here.
1+
MIT License
2+
3+
Copyright (c) 2024 Anthony Gordon
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 125 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,129 @@
1-
# laravel_notify_fcm
1+
# Laravel Notify Fcm
22

3-
A new Flutter package.
3+
<p align="center">
4+
<a href="https://github.com/nylo-core/laravel-notify-fcm/releases/latest"><img src="https://img.shields.io/github/v/release/nylo-core/laravel-notify-fcm?style=plastic" alt="Latest Release Version"></a>
5+
<a href="https://github.com/nylo-core/laravel-notify-fcm/releases/latest"><img src="https://img.shields.io/github/license/nylo-core/laravel-notify-fcm?style=plastic" alt="Latest Stable Version"></a>
6+
<a href="https://github.com/nylo-core/laravel-notify-fcm"><img alt="GitHub stars" src="https://img.shields.io/github/stars/nylo-core/laravel-notify-fcm?style=plastic"></a>
7+
</p>
48

5-
## Getting Started
9+
Laravel Notify Fcm if package for sending notifications to your Flutter app using Laravel FCM.
610

7-
This project is a starting point for a Dart
8-
[package](https://flutter.dev/developing-packages/),
9-
a library module containing code that can be shared easily across
10-
multiple Flutter or Dart projects.
11+
## Getting started
1112

12-
For help getting started with Flutter, view our
13-
[online documentation](https://flutter.dev/docs), which offers tutorials,
14-
samples, guidance on mobile development, and a full API reference.
13+
### Installation
14+
15+
Add the following to your `pubspec.yaml` file:
16+
17+
``` yaml
18+
dependencies:
19+
laravel_notify_fcm: ^0.0.1
20+
```
21+
22+
or with Dart:
23+
24+
``` bash
25+
dart pub add laravel_notify_fcm
26+
```
27+
28+
### Requirements
29+
30+
## Installation
31+
32+
First, install the package via composer:
33+
34+
``` bash
35+
composer require nylo-core/laravel-fcm-channel
36+
```
37+
38+
The package will automatically register itself.
39+
40+
## Configuration
41+
42+
Run the `install` command.
43+
44+
```bash
45+
php artisan laravelfcm:install
46+
```
47+
This will add a (`laravelfcm.php`) config file
48+
49+
ServiceProvider to your app.php: `App\Providers\FcmAppServiceProvider::class`
50+
51+
Then, ask if you want to run the migrations.
52+
53+
Here's the tables it will migrate:
54+
* fcm_devices
55+
56+
Add your Google Service Account to `firebase_service_account_json`.
57+
58+
```php
59+
<?php
60+
61+
return '{
62+
"type": "service_account",
63+
"project_id": "123456789-me908",
64+
"private_key_id": "123456789",
65+
"private_key": "-----BEGIN PRIVATE KEY-----\123456789\n-----END PRIVATE KEY-----\n",
66+
"client_email": "firebase-adminsdk-9p9z7@123456789-me908.iam.gserviceaccount.com",
67+
"client_id": "123456789",
68+
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
69+
"token_uri": "https://oauth2.googleapis.com/token",
70+
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
71+
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-9p9z7%123456789-me908.iam.gserviceaccount.com",
72+
"universe_domain": "googleapis.com"
73+
}';
74+
```
75+
76+
You can download your Google Service Account in your Firebase Project Settings > Service Accounts > Manage service account permissions > "Actions (three dots) - Manage keys" > Add Key > Create New Key.
77+
78+
Then, paste the JSON into the `firebase_service_account_json` file like in the above example.
79+
> **Note:** It's best to keep the key values in a `.env` file. Don't commit the JSON file to your repository.
80+
81+
You can fully configure this package in the `config/laravelfcm.php` file (this file should be added after you run `php artisan laravelfcm:install`).
82+
83+
### Usage
84+
85+
``` dart
86+
import 'package:laravel_notify_fcm/laravel_notify_fcm.dart';
87+
88+
```
89+
90+
### Adding a device to the database
91+
92+
First, call `init` to initialize the package.
93+
94+
Parameters:
95+
- `url` - The URL to your Laravel app where the package will send the device token.
96+
- `firebaseMessaging` - The FirebaseMessaging instance.
97+
- `debugMode` - Whether to enable debug mode. Default is `false`.
98+
99+
```dart
100+
FirebaseMessaging firebaseMessaging = FirebaseMessaging();
101+
102+
await LaravelNotifyFcm.instance.init(
103+
url: 'https://example.com/api/fcm/devices',
104+
firebaseMessaging: firebaseMessaging,
105+
);
106+
```
107+
108+
Then, call `storeFcmDevice` to add the device to the database.
109+
110+
``` dart
111+
112+
await LaravelNotifyFcm.instance.storeFcmDevice(
113+
sanctumToken: 'from your laravel user',
114+
);
115+
```
116+
117+
This method will request permission to send notifications to the device. If the user accepts, the device will be added to the database.
118+
119+
Try the [example](/example) app to see how it works.
120+
121+
## Changelog
122+
Please see [CHANGELOG](https://github.com/nylo-core/laravel-notify-fcm/blob/master/CHANGELOG.md) for more information what has changed recently.
123+
124+
## Social
125+
* [Twitter](https://twitter.com/nylo_dev)
126+
127+
## Licence
128+
129+
The MIT License (MIT). Please view the [License](https://github.com/nylo-core/laravel-notify-fcm/blob/main/LICENSE) File for more information.

lib/helpers/tools.dart

Lines changed: 0 additions & 11 deletions
This file was deleted.

lib/interceptor_fcm_request.dart

Lines changed: 0 additions & 64 deletions
This file was deleted.

0 commit comments

Comments
 (0)