Skip to content

Commit

Permalink
add: デバッグ時にFCM・APNS Tokenを表示するように (#434)
Browse files Browse the repository at this point in the history
  • Loading branch information
YumNumm authored Dec 4, 2023
1 parent f8f3d8c commit 03ba97c
Show file tree
Hide file tree
Showing 6 changed files with 526 additions and 159 deletions.
5 changes: 0 additions & 5 deletions lib/core/provider/fcm_token.dart

This file was deleted.

31 changes: 31 additions & 0 deletions lib/core/provider/notification_token.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import 'package:eqmonitor/core/provider/firebase/firebase_messaging.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

part 'notification_token.freezed.dart';
part 'notification_token.g.dart';

@riverpod
Future<NotificationTokenModel> notificationToken(NotificationTokenRef ref) async {
final messaging = ref.watch(firebaseMessagingProvider);
final results = await (
messaging.getAPNSToken(),
messaging.getToken(),
).wait;

return NotificationTokenModel(
apnsToken: results.$1,
fcmToken: results.$2,
);
}

@freezed
class NotificationTokenModel with _$NotificationTokenModel {
const factory NotificationTokenModel({
required String? fcmToken,
required String? apnsToken,
}) = _NotificationTokenModel;

factory NotificationTokenModel.fromJson(Map<String, dynamic> json) =>
_$NotificationTokenModelFromJson(json);
}
178 changes: 178 additions & 0 deletions lib/core/provider/notification_token.freezed.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 54 additions & 0 deletions lib/core/provider/notification_token.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file.
Loading

0 comments on commit 03ba97c

Please sign in to comment.