mirror of
https://github.com/nostrlabs-io/zap-stream-flutter.git
synced 2025-06-13 19:22:48 +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 {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
LocaleSettings.useDeviceLocale();
|
||||
// FCM DELETE
|
||||
await initLogin();
|
||||
|
||||
runZapStream();
|
||||
|
@ -1,7 +1,8 @@
|
||||
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_dotenv/flutter_dotenv.dart';
|
||||
import 'package:zap_stream_flutter/app.dart';
|
||||
import 'package:zap_stream_flutter/const.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 {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
LocaleSettings.useDeviceLocale();
|
||||
await Firebase.initializeApp();
|
||||
await dotenv.load(fileName: kDebugMode ? ".env.development" : ".env");
|
||||
|
||||
await initLogin();
|
||||
|
||||
setupNotifications().catchError((e) {
|
||||
|
@ -1,7 +1,9 @@
|
||||
import 'dart:developer' as developer;
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:firebase_core/firebase_core.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:ndk/ndk.dart';
|
||||
import 'package:zap_stream_flutter/const.dart';
|
||||
@ -19,14 +21,16 @@ class Notepush {
|
||||
"$base/user-info/$pubkey/${Uri.encodeComponent(token)}?backend=fcm";
|
||||
developer.log(url);
|
||||
final auth = await _makeAuth("PUT", url);
|
||||
final rsp = await http.put(
|
||||
Uri.parse(url),
|
||||
headers: {
|
||||
"authorization": "Nostr $auth",
|
||||
"accept": "application/json",
|
||||
"content-type": "application/json",
|
||||
},
|
||||
);
|
||||
final rsp = await http
|
||||
.put(
|
||||
Uri.parse(url),
|
||||
headers: {
|
||||
"authorization": "Nostr $auth",
|
||||
"accept": "application/json",
|
||||
"content-type": "application/json",
|
||||
},
|
||||
)
|
||||
.timeout(Duration(seconds: 10));
|
||||
developer.log(rsp.body);
|
||||
return rsp.body;
|
||||
}
|
||||
@ -48,9 +52,11 @@ class Notepush {
|
||||
}
|
||||
|
||||
Future<void> setupNotifications() async {
|
||||
await Firebase.initializeApp();
|
||||
|
||||
final signer = ndk.accounts.getLoggedAccount()?.signer;
|
||||
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;
|
||||
FirebaseMessaging.onMessage.listen((msg) {
|
||||
developer.log(msg.notification?.body ?? "");
|
||||
|
@ -366,6 +366,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
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:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
|
@ -43,6 +43,7 @@ dependencies:
|
||||
firebase_messaging: ^15.2.6
|
||||
http: ^1.4.0
|
||||
flutter_local_notifications: ^19.2.1
|
||||
flutter_dotenv: ^5.2.1
|
||||
|
||||
dependency_overrides:
|
||||
ndk:
|
||||
@ -79,6 +80,8 @@ dev_dependencies:
|
||||
flutter:
|
||||
uses-material-design: true
|
||||
assets:
|
||||
- ".env"
|
||||
- ".env.development"
|
||||
- "assets/svg/"
|
||||
- "assets/logo.png"
|
||||
- "assets/category/"
|
||||
|
Reference in New Issue
Block a user