Skip to content

Commit c362956

Browse files
committed
v1.0.0
1 parent 96402d3 commit c362956

File tree

9 files changed

+180
-51
lines changed

9 files changed

+180
-51
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## [1.0.0] - 2024-06-10
2+
3+
* Update README.md
4+
* Fix bug with API Service and request headers.
5+
16
## [0.0.4] - 2024-06-09
27

38
* Update README.md.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Add the following to your `pubspec.yaml` file:
1616

1717
``` yaml
1818
dependencies:
19-
laravel_notify_fcm: ^0.0.4
19+
laravel_notify_fcm: ^1.0.0
2020
```
2121
2222
or with Dart:

example/ios/Podfile.lock

Lines changed: 105 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,143 @@
11
PODS:
2+
- device_info_plus (0.0.1):
3+
- Flutter
4+
- Firebase/CoreOnly (10.25.0):
5+
- FirebaseCore (= 10.25.0)
6+
- Firebase/Messaging (10.25.0):
7+
- Firebase/CoreOnly
8+
- FirebaseMessaging (~> 10.25.0)
9+
- firebase_core (2.32.0):
10+
- Firebase/CoreOnly (= 10.25.0)
11+
- Flutter
12+
- firebase_messaging (14.9.4):
13+
- Firebase/Messaging (= 10.25.0)
14+
- firebase_core
15+
- Flutter
16+
- FirebaseCore (10.25.0):
17+
- FirebaseCoreInternal (~> 10.0)
18+
- GoogleUtilities/Environment (~> 7.12)
19+
- GoogleUtilities/Logger (~> 7.12)
20+
- FirebaseCoreInternal (10.27.0):
21+
- "GoogleUtilities/NSData+zlib (~> 7.8)"
22+
- FirebaseInstallations (10.27.0):
23+
- FirebaseCore (~> 10.0)
24+
- GoogleUtilities/Environment (~> 7.8)
25+
- GoogleUtilities/UserDefaults (~> 7.8)
26+
- PromisesObjC (~> 2.1)
27+
- FirebaseMessaging (10.25.0):
28+
- FirebaseCore (~> 10.0)
29+
- FirebaseInstallations (~> 10.0)
30+
- GoogleDataTransport (~> 9.3)
31+
- GoogleUtilities/AppDelegateSwizzler (~> 7.8)
32+
- GoogleUtilities/Environment (~> 7.8)
33+
- GoogleUtilities/Reachability (~> 7.8)
34+
- GoogleUtilities/UserDefaults (~> 7.8)
35+
- nanopb (< 2.30911.0, >= 2.30908.0)
236
- Flutter (1.0.0)
337
- flutter_secure_storage (6.0.0):
438
- Flutter
5-
- FMDB (2.7.5):
6-
- FMDB/standard (= 2.7.5)
7-
- FMDB/standard (2.7.5)
8-
- image_picker_ios (0.0.1):
9-
- Flutter
39+
- GoogleDataTransport (9.4.1):
40+
- GoogleUtilities/Environment (~> 7.7)
41+
- nanopb (< 2.30911.0, >= 2.30908.0)
42+
- PromisesObjC (< 3.0, >= 1.2)
43+
- GoogleUtilities/AppDelegateSwizzler (7.13.3):
44+
- GoogleUtilities/Environment
45+
- GoogleUtilities/Logger
46+
- GoogleUtilities/Network
47+
- GoogleUtilities/Privacy
48+
- GoogleUtilities/Environment (7.13.3):
49+
- GoogleUtilities/Privacy
50+
- PromisesObjC (< 3.0, >= 1.2)
51+
- GoogleUtilities/Logger (7.13.3):
52+
- GoogleUtilities/Environment
53+
- GoogleUtilities/Privacy
54+
- GoogleUtilities/Network (7.13.3):
55+
- GoogleUtilities/Logger
56+
- "GoogleUtilities/NSData+zlib"
57+
- GoogleUtilities/Privacy
58+
- GoogleUtilities/Reachability
59+
- "GoogleUtilities/NSData+zlib (7.13.3)":
60+
- GoogleUtilities/Privacy
61+
- GoogleUtilities/Privacy (7.13.3)
62+
- GoogleUtilities/Reachability (7.13.3):
63+
- GoogleUtilities/Logger
64+
- GoogleUtilities/Privacy
65+
- GoogleUtilities/UserDefaults (7.13.3):
66+
- GoogleUtilities/Logger
67+
- GoogleUtilities/Privacy
68+
- nanopb (2.30910.0):
69+
- nanopb/decode (= 2.30910.0)
70+
- nanopb/encode (= 2.30910.0)
71+
- nanopb/decode (2.30910.0)
72+
- nanopb/encode (2.30910.0)
1073
- path_provider_foundation (0.0.1):
1174
- Flutter
1275
- FlutterMacOS
76+
- PromisesObjC (2.4.0)
1377
- shared_preferences_foundation (0.0.1):
1478
- Flutter
1579
- FlutterMacOS
16-
- sqflite (0.0.3):
80+
- url_launcher_ios (0.0.1):
1781
- Flutter
18-
- FMDB (>= 2.7.5)
1982

2083
DEPENDENCIES:
84+
- device_info_plus (from `.symlinks/plugins/device_info_plus/ios`)
85+
- firebase_core (from `.symlinks/plugins/firebase_core/ios`)
86+
- firebase_messaging (from `.symlinks/plugins/firebase_messaging/ios`)
2187
- Flutter (from `Flutter`)
2288
- flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`)
23-
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
2489
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
2590
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
26-
- sqflite (from `.symlinks/plugins/sqflite/ios`)
91+
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
2792

2893
SPEC REPOS:
2994
trunk:
30-
- FMDB
95+
- Firebase
96+
- FirebaseCore
97+
- FirebaseCoreInternal
98+
- FirebaseInstallations
99+
- FirebaseMessaging
100+
- GoogleDataTransport
101+
- GoogleUtilities
102+
- nanopb
103+
- PromisesObjC
31104

32105
EXTERNAL SOURCES:
106+
device_info_plus:
107+
:path: ".symlinks/plugins/device_info_plus/ios"
108+
firebase_core:
109+
:path: ".symlinks/plugins/firebase_core/ios"
110+
firebase_messaging:
111+
:path: ".symlinks/plugins/firebase_messaging/ios"
33112
Flutter:
34113
:path: Flutter
35114
flutter_secure_storage:
36115
:path: ".symlinks/plugins/flutter_secure_storage/ios"
37-
image_picker_ios:
38-
:path: ".symlinks/plugins/image_picker_ios/ios"
39116
path_provider_foundation:
40117
:path: ".symlinks/plugins/path_provider_foundation/darwin"
41118
shared_preferences_foundation:
42119
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
43-
sqflite:
44-
:path: ".symlinks/plugins/sqflite/ios"
120+
url_launcher_ios:
121+
:path: ".symlinks/plugins/url_launcher_ios/ios"
45122

46123
SPEC CHECKSUMS:
124+
device_info_plus: 97af1d7e84681a90d0693e63169a5d50e0839a0d
125+
Firebase: 0312a2352584f782ea56f66d91606891d4607f06
126+
firebase_core: a626d00494efa398e7c54f25f1454a64c8abf197
127+
firebase_messaging: 06391e8f35dc65a00c56580266285263d2861f10
128+
FirebaseCore: 7ec4d0484817f12c3373955bc87762d96842d483
129+
FirebaseCoreInternal: 4b297a2d56063dbea2c1d0d04222d44a8d058862
130+
FirebaseInstallations: 766dabca09fd94aef922538aaf144cc4a6fb6869
131+
FirebaseMessaging: 88950ba9485052891ebe26f6c43a52bb62248952
47132
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
48-
flutter_secure_storage: 23fc622d89d073675f2eaa109381aefbcf5a49be
49-
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
50-
image_picker_ios: 4a8aadfbb6dc30ad5141a2ce3832af9214a705b5
133+
flutter_secure_storage: d33dac7ae2ea08509be337e775f6b59f1ff45f12
134+
GoogleDataTransport: 6c09b596d841063d76d4288cc2d2f42cc36e1e2a
135+
GoogleUtilities: ea963c370a38a8069cc5f7ba4ca849a60b6d7d15
136+
nanopb: 438bc412db1928dac798aa6fd75726007be04262
51137
path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943
138+
PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47
52139
shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126
53-
sqflite: 31f7eba61e3074736dff8807a9b41581e4f7f15a
140+
url_launcher_ios: 6116280ddcfe98ab8820085d8d76ae7449447586
54141

55142
PODFILE CHECKSUM: 819463e6a0290f5a72f145ba7cde16e8b6ef0796
56143

example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@
199199
9705A1C41CF9048500538489 /* Embed Frameworks */,
200200
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
201201
4DF60671BED5077475A8F7A7 /* [CP] Embed Pods Frameworks */,
202+
B38A08238ECA3DF62C64F5BF /* [CP] Copy Pods Resources */,
202203
);
203204
buildRules = (
204205
);
@@ -362,6 +363,23 @@
362363
shellPath = /bin/sh;
363364
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
364365
};
366+
B38A08238ECA3DF62C64F5BF /* [CP] Copy Pods Resources */ = {
367+
isa = PBXShellScriptBuildPhase;
368+
buildActionMask = 2147483647;
369+
files = (
370+
);
371+
inputFileListPaths = (
372+
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist",
373+
);
374+
name = "[CP] Copy Pods Resources";
375+
outputFileListPaths = (
376+
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist",
377+
);
378+
runOnlyForDeploymentPostprocessing = 0;
379+
shellPath = /bin/sh;
380+
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
381+
showEnvVarsInLog = 0;
382+
};
365383
/* End PBXShellScriptBuildPhase section */
366384

367385
/* Begin PBXSourcesBuildPhase section */

example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ packages:
323323
path: ".."
324324
relative: true
325325
source: path
326-
version: "0.0.3"
326+
version: "0.0.4"
327327
leak_tracker:
328328
dependency: transitive
329329
description:

lib/laravel_notify_fcm.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import 'package:firebase_messaging/firebase_messaging.dart';
77
import 'package:laravel_notify_fcm/networking/laravel_fcm_api_service.dart';
88

99
/// LaravelNotifyFcm version
10-
const String _laravelNotifyFcmVersion = '0.0.4';
10+
const String _laravelNotifyFcmVersion = '1.0.0';
1111

1212
/// LaravelNotifyFcm class
1313
class LaravelNotifyFcm {
@@ -157,13 +157,15 @@ class LaravelNotifyFcm {
157157
/// Enable FCM device
158158
static Future<bool> enableFcmDevice() async {
159159
return await LaravelNotifyFcm.apiServiceFcm(
160-
(api) => api.createOrUpdateDevice(active: true));
160+
(api) => api.createOrUpdateDevice(active: true)) ??
161+
false;
161162
}
162163

163164
/// Disable FCM device
164165
static Future<bool> disableFcmDevice() async {
165166
return await LaravelNotifyFcm.apiServiceFcm(
166-
(api) => api.createOrUpdateDevice(active: false));
167+
(api) => api.createOrUpdateDevice(active: false)) ??
168+
false;
167169
}
168170

169171
/// Get the LaravelFcmApiService instance
Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,28 @@
1+
import 'dart:convert';
2+
13
import 'package:dio/dio.dart';
24
import 'package:laravel_notify_fcm/laravel_notify_fcm.dart';
35

46
class InterceptorNotifyFCM extends InterceptorsWrapper {
57
@override
68
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
7-
options.headers
8-
.addAll({"X-DMETA": LaravelNotifyFcm.instance.getDeviceMetaJson()});
9+
Map<String, dynamic> deviceMeta =
10+
LaravelNotifyFcm.instance.getDeviceMetaJson();
11+
12+
options.headers.addAll({
13+
"X-DMETA": jsonEncode({
14+
"uuid": deviceMeta['uuid'],
15+
"model": deviceMeta['model'],
16+
"display_name": deviceMeta['name'],
17+
"platform": deviceMeta['platform_type'],
18+
"version": deviceMeta['version'],
19+
})
20+
});
21+
22+
String? sanctumToken = LaravelNotifyFcm.instance.getSanctumToken();
23+
if (sanctumToken != null) {
24+
options.headers.addAll({"Authorization": "Bearer $sanctumToken"});
25+
}
926
return handler.next(options);
1027
}
1128
}

lib/networking/laravel_fcm_api_service.dart

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ class LaravelFcmApiService extends NyApiService {
2020
);
2121

2222
@override
23-
final interceptors = {
24-
if (getEnv('APP_DEBUG', defaultValue: true) == true)
25-
PrettyDioLogger: PrettyDioLogger(),
26-
InterceptorNotifyFCM: InterceptorNotifyFCM(),
27-
};
23+
get interceptors => {
24+
if (getEnv('APP_DEBUG', defaultValue: true) == true)
25+
PrettyDioLogger: PrettyDioLogger(),
26+
InterceptorNotifyFCM: InterceptorNotifyFCM(),
27+
};
2828

2929
/// Laravel FCM URL
3030
String get urlLaravel => LaravelNotifyFcm.instance.getUrl();
@@ -33,27 +33,27 @@ class LaravelFcmApiService extends NyApiService {
3333
String? get sanctumToken => LaravelNotifyFcm.instance.getSanctumToken();
3434

3535
/// Create or update device
36-
Future<bool> createOrUpdateDevice({bool active = true}) async {
36+
Future<bool?> createOrUpdateDevice({bool active = true}) async {
3737
String? fcmToken = await LaravelNotifyFcm.getFcmToken();
3838
return await network(
39-
request: (api) => api.put("/device", data: {
40-
"is_active": (active == true ? 1 : 0),
41-
"fcm_token": fcmToken,
42-
}),
43-
baseUrl: urlLaravel);
44-
}
45-
46-
/* Authentication Headers
47-
|--------------------------------------------------------------------------
48-
| Set your auth headers
49-
| Authenticate your API requests using a bearer token or any other method
50-
|-------------------------------------------------------------------------- */
51-
52-
@override
53-
Future<RequestHeaders> setAuthHeaders(RequestHeaders headers) async {
54-
if (sanctumToken != null) {
55-
headers.addBearerToken(sanctumToken!);
56-
}
57-
return headers;
39+
request: (api) => api.put("/device", data: {
40+
"is_active": (active == true ? 1 : 0),
41+
"fcm_token": fcmToken,
42+
}),
43+
baseUrl: urlLaravel,
44+
handleSuccess: (response) {
45+
if (response.data == null) {
46+
return false;
47+
}
48+
dynamic data = response.data;
49+
if (!(data is Map)) {
50+
return false;
51+
}
52+
if (data.containsKey('status') && data['status'] == 200) {
53+
return true;
54+
}
55+
return false;
56+
},
57+
);
5858
}
5959
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: laravel_notify_fcm
22
description: "Laravel Notify for Firebase Cloud Messaging (FCM) - Send push notifications to your Flutter app from Laravel."
3-
version: 0.0.4
3+
version: 1.0.0
44
homepage: https://nylo.dev
55
repository: https://github.com/nylo-core/laravel-notify-fcm
66
issue_tracker: https://github.com/nylo-core/laravel-notify-fcm/issues

0 commit comments

Comments
 (0)