mirror of
https://github.com/nostrlabs-io/zap-stream-flutter.git
synced 2025-06-14 19:36:33 +00:00
feat: setup env vars
This commit is contained in:
1
.env.development
Normal file
1
.env.development
Normal file
@ -0,0 +1 @@
|
|||||||
|
NOTEPUSH_URL="http://10.0.2.2:8000"
|
@ -6,7 +6,6 @@ import 'package:zap_stream_flutter/i18n/strings.g.dart';
|
|||||||
Future<void> main() async {
|
Future<void> main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
LocaleSettings.useDeviceLocale();
|
LocaleSettings.useDeviceLocale();
|
||||||
// FCM DELETE
|
|
||||||
await initLogin();
|
await initLogin();
|
||||||
|
|
||||||
runZapStream();
|
runZapStream();
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import 'dart:developer' as developer;
|
import 'dart:developer' as developer;
|
||||||
|
|
||||||
import 'package:firebase_core/firebase_core.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||||
import 'package:zap_stream_flutter/app.dart';
|
import 'package:zap_stream_flutter/app.dart';
|
||||||
import 'package:zap_stream_flutter/const.dart';
|
import 'package:zap_stream_flutter/const.dart';
|
||||||
import 'package:zap_stream_flutter/i18n/strings.g.dart';
|
import 'package:zap_stream_flutter/i18n/strings.g.dart';
|
||||||
@ -10,7 +11,8 @@ import 'package:zap_stream_flutter/notifications.dart';
|
|||||||
Future<void> main() async {
|
Future<void> main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
LocaleSettings.useDeviceLocale();
|
LocaleSettings.useDeviceLocale();
|
||||||
await Firebase.initializeApp();
|
await dotenv.load(fileName: kDebugMode ? ".env.development" : ".env");
|
||||||
|
|
||||||
await initLogin();
|
await initLogin();
|
||||||
|
|
||||||
setupNotifications().catchError((e) {
|
setupNotifications().catchError((e) {
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
import 'dart:developer' as developer;
|
import 'dart:developer' as developer;
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:firebase_core/firebase_core.dart';
|
||||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||||
|
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||||
import 'package:ndk/ndk.dart';
|
import 'package:ndk/ndk.dart';
|
||||||
import 'package:zap_stream_flutter/const.dart';
|
import 'package:zap_stream_flutter/const.dart';
|
||||||
@ -19,14 +21,16 @@ class Notepush {
|
|||||||
"$base/user-info/$pubkey/${Uri.encodeComponent(token)}?backend=fcm";
|
"$base/user-info/$pubkey/${Uri.encodeComponent(token)}?backend=fcm";
|
||||||
developer.log(url);
|
developer.log(url);
|
||||||
final auth = await _makeAuth("PUT", url);
|
final auth = await _makeAuth("PUT", url);
|
||||||
final rsp = await http.put(
|
final rsp = await http
|
||||||
Uri.parse(url),
|
.put(
|
||||||
headers: {
|
Uri.parse(url),
|
||||||
"authorization": "Nostr $auth",
|
headers: {
|
||||||
"accept": "application/json",
|
"authorization": "Nostr $auth",
|
||||||
"content-type": "application/json",
|
"accept": "application/json",
|
||||||
},
|
"content-type": "application/json",
|
||||||
);
|
},
|
||||||
|
)
|
||||||
|
.timeout(Duration(seconds: 10));
|
||||||
developer.log(rsp.body);
|
developer.log(rsp.body);
|
||||||
return rsp.body;
|
return rsp.body;
|
||||||
}
|
}
|
||||||
@ -48,9 +52,11 @@ class Notepush {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> setupNotifications() async {
|
Future<void> setupNotifications() async {
|
||||||
|
await Firebase.initializeApp();
|
||||||
|
|
||||||
final signer = ndk.accounts.getLoggedAccount()?.signer;
|
final signer = ndk.accounts.getLoggedAccount()?.signer;
|
||||||
if (signer != null) {
|
if (signer != null) {
|
||||||
final pusher = Notepush("http://10.0.2.2:8000", signer: signer);
|
final pusher = Notepush(dotenv.env["NOTEPUSH_URL"]!, signer: signer);
|
||||||
final fbase = FirebaseMessaging.instance;
|
final fbase = FirebaseMessaging.instance;
|
||||||
FirebaseMessaging.onMessage.listen((msg) {
|
FirebaseMessaging.onMessage.listen((msg) {
|
||||||
developer.log(msg.notification?.body ?? "");
|
developer.log(msg.notification?.body ?? "");
|
||||||
|
@ -366,6 +366,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.4.1"
|
version: "3.4.1"
|
||||||
|
flutter_dotenv:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: flutter_dotenv
|
||||||
|
sha256: b7c7be5cd9f6ef7a78429cabd2774d3c4af50e79cb2b7593e3d5d763ef95c61b
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "5.2.1"
|
||||||
flutter_lints:
|
flutter_lints:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
|
@ -43,6 +43,7 @@ dependencies:
|
|||||||
firebase_messaging: ^15.2.6
|
firebase_messaging: ^15.2.6
|
||||||
http: ^1.4.0
|
http: ^1.4.0
|
||||||
flutter_local_notifications: ^19.2.1
|
flutter_local_notifications: ^19.2.1
|
||||||
|
flutter_dotenv: ^5.2.1
|
||||||
|
|
||||||
dependency_overrides:
|
dependency_overrides:
|
||||||
ndk:
|
ndk:
|
||||||
@ -79,6 +80,8 @@ dev_dependencies:
|
|||||||
flutter:
|
flutter:
|
||||||
uses-material-design: true
|
uses-material-design: true
|
||||||
assets:
|
assets:
|
||||||
|
- ".env"
|
||||||
|
- ".env.development"
|
||||||
- "assets/svg/"
|
- "assets/svg/"
|
||||||
- "assets/logo.png"
|
- "assets/logo.png"
|
||||||
- "assets/category/"
|
- "assets/category/"
|
||||||
|
Reference in New Issue
Block a user