mirror of
https://github.com/nostrlabs-io/zap-stream-flutter.git
synced 2025-06-14 11:27:43 +00:00
fix: notifications icon
This commit is contained in:
@ -1,6 +1,10 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools">
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
|
<uses-feature
|
||||||
|
android:name="android.hardware.camera"
|
||||||
|
android:required="false" />
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
|
@ -241,7 +241,7 @@ Future<void> _showNotification(
|
|||||||
android: AndroidNotificationDetails(
|
android: AndroidNotificationDetails(
|
||||||
notification.android!.channelId ?? "fcm",
|
notification.android!.channelId ?? "fcm",
|
||||||
"Push Notifications",
|
"Push Notifications",
|
||||||
category: AndroidNotificationCategory.social
|
category: AndroidNotificationCategory.social,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -270,45 +270,48 @@ Future<void> setupNotifications() async {
|
|||||||
|
|
||||||
final signer = ndk.accounts.getLoggedAccount()?.signer;
|
final signer = ndk.accounts.getLoggedAccount()?.signer;
|
||||||
if (signer != null) {
|
if (signer != null) {
|
||||||
FirebaseMessaging.onMessage.listen(_onNotification);
|
await configureNotifications(signer);
|
||||||
//FirebaseMessaging.onBackgroundMessage(_onBackgroundNotification);
|
|
||||||
FirebaseMessaging.onMessageOpenedApp.listen(_onOpenMessage);
|
|
||||||
|
|
||||||
final settings = await FirebaseMessaging.instance.requestPermission(
|
|
||||||
provisional: true,
|
|
||||||
);
|
|
||||||
await FirebaseMessaging.instance.setAutoInitEnabled(true);
|
|
||||||
await FirebaseMessaging.instance
|
|
||||||
.setForegroundNotificationPresentationOptions(
|
|
||||||
alert: true,
|
|
||||||
badge: true,
|
|
||||||
sound: true,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (Platform.isIOS) {
|
|
||||||
final apnsToken = await FirebaseMessaging.instance.getAPNSToken();
|
|
||||||
if (apnsToken == null) {
|
|
||||||
throw "APNS token not availble";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
await _initLocalNotifications();
|
|
||||||
|
|
||||||
final pusher = Notepush(dotenv.env["NOTEPUSH_URL"]!, signer: signer);
|
|
||||||
FirebaseMessaging.instance.onTokenRefresh.listen((token) async {
|
|
||||||
developer.log("NEW TOKEN: $token");
|
|
||||||
await pusher.register(token);
|
|
||||||
await pusher.setNotificationSettings(token, [30_311]);
|
|
||||||
});
|
|
||||||
|
|
||||||
final fcmToken = await FirebaseMessaging.instance.getToken();
|
|
||||||
if (fcmToken == null) {
|
|
||||||
throw "Push token is null";
|
|
||||||
}
|
|
||||||
await pusher.register(fcmToken);
|
|
||||||
await pusher.setNotificationSettings(fcmToken, [30_311]);
|
|
||||||
|
|
||||||
notifications.value = await NotificationsState.init(
|
|
||||||
settings.authorizationStatus,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> configureNotifications(EventSigner signer) async {
|
||||||
|
FirebaseMessaging.onMessage.listen(_onNotification);
|
||||||
|
//FirebaseMessaging.onBackgroundMessage(_onBackgroundNotification);
|
||||||
|
FirebaseMessaging.onMessageOpenedApp.listen(_onOpenMessage);
|
||||||
|
|
||||||
|
final settings = await FirebaseMessaging.instance.requestPermission(
|
||||||
|
provisional: true,
|
||||||
|
);
|
||||||
|
await FirebaseMessaging.instance.setAutoInitEnabled(true);
|
||||||
|
await FirebaseMessaging.instance.setForegroundNotificationPresentationOptions(
|
||||||
|
alert: true,
|
||||||
|
badge: true,
|
||||||
|
sound: true,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (Platform.isIOS) {
|
||||||
|
final apnsToken = await FirebaseMessaging.instance.getAPNSToken();
|
||||||
|
if (apnsToken == null) {
|
||||||
|
throw "APNS token not availble";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await _initLocalNotifications();
|
||||||
|
|
||||||
|
final pusher = Notepush(dotenv.env["NOTEPUSH_URL"]!, signer: signer);
|
||||||
|
FirebaseMessaging.instance.onTokenRefresh.listen((token) async {
|
||||||
|
developer.log("NEW TOKEN: $token");
|
||||||
|
await pusher.register(token);
|
||||||
|
await pusher.setNotificationSettings(token, [30_311]);
|
||||||
|
});
|
||||||
|
|
||||||
|
final fcmToken = await FirebaseMessaging.instance.getToken();
|
||||||
|
if (fcmToken == null) {
|
||||||
|
throw "Push token is null";
|
||||||
|
}
|
||||||
|
await pusher.register(fcmToken);
|
||||||
|
await pusher.setNotificationSettings(fcmToken, [30_311]);
|
||||||
|
|
||||||
|
notifications.value = await NotificationsState.init(
|
||||||
|
settings.authorizationStatus,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
@ -17,7 +17,8 @@ class _NotificationsButtonWidget extends State<NotificationsButtonWidget> {
|
|||||||
return ValueListenableBuilder(
|
return ValueListenableBuilder(
|
||||||
valueListenable: notifications,
|
valueListenable: notifications,
|
||||||
builder: (context, state, _) {
|
builder: (context, state, _) {
|
||||||
final isNotified = (state?.notifyKeys ?? []).contains(widget.pubkey);
|
if (state == null) return SizedBox();
|
||||||
|
final isNotified = state.notifyKeys.contains(widget.pubkey);
|
||||||
return IconButton(
|
return IconButton(
|
||||||
iconSize: 20,
|
iconSize: 20,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
|
Reference in New Issue
Block a user