Commit 2e705874 authored by Gavin An's avatar Gavin An

여러가지 테스트

parent 7421b5a0
......@@ -22,6 +22,22 @@
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher"
android:label="dispatcher_test">
<!-- 카카오 로그인 커스텀 URL 스킴 설정 -->
<activity
android:name="com.kakao.sdk.flutter.AuthCodeCustomTabsActivity"
android:exported="true">
<intent-filter android:label="flutter_web_auth">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- "kakao${YOUR_NATIVE_APP_KEY}://oauth" 형식의 앱 실행 스킴 설정 -->
<!-- 카카오 로그인 Redirect URI -->
<!-- <data android:scheme="kakao${564563452}" android:host="oauth"/>-->
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
......
......@@ -2,6 +2,7 @@ import 'dart:math';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:dispatcher_test/firebase_options.dart';
import 'package:dispatcher_test/module/dependency_inject.dart';
import 'package:dispatcher_test/notification_page.dart';
import 'package:dispatcher_test/speech_to_text_page.dart';
import 'package:dispatcher_test/text_to_speech_page.dart';
......@@ -10,7 +11,9 @@ import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:kakao_flutter_sdk_user/kakao_flutter_sdk_user.dart';
import 'package:permission_handler/permission_handler.dart';
const List<String> sample = [
......@@ -75,7 +78,7 @@ Future<void> setupFlutterNotifications() async {
'high_importance_channel', // id
'High Importance Notifications', // title
description:
'This channel is used for important notifications.', // description
'This channel is used for important notifications.', // description
importance: Importance.high,
);
......@@ -85,14 +88,14 @@ Future<void> setupFlutterNotifications() async {
///
/// We use this channel in the `AndroidManifest.xml` file to override the
/// default FCM channel to enable heads up notifications.
await flutterLocalNotificationsPlugin.resolvePlatformSpecificImplementation
<AndroidFlutterLocalNotificationsPlugin>()?.createNotificationChannel(channel);
await flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>()
?.createNotificationChannel(channel);
/// Update the iOS foreground notification presentation options to allow
/// heads up notifications.
await FirebaseMessaging
.instance
.setForegroundNotificationPresentationOptions(
await FirebaseMessaging.instance.setForegroundNotificationPresentationOptions(
alert: true,
badge: true,
sound: true,
......@@ -100,15 +103,21 @@ Future<void> setupFlutterNotifications() async {
isFlutterLocalNotificationsInitialized = true;
}
void main() async {
WidgetsFlutterBinding.ensureInitialized();
dependenciesInitialized();
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
// FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
FirebaseFirestore.instance.settings = const Settings(
persistenceEnabled: true,
);
// TODO 카카오 Login
// KakaoSdk.init(
// nativeAppKey: ''
// );
// final fcmToken = await FirebaseMessaging.instance.getToken();
// print('fcmToken: $fcmToken');
if (!kIsWeb) {
......@@ -136,6 +145,7 @@ class MyApp extends StatelessWidget {
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
......@@ -222,6 +232,33 @@ class _MyHomePageState extends State<MyHomePage> {
style: TextStyle(color: Colors.black),
),
),
TextButton(
style: const ButtonStyle(
backgroundColor: WidgetStatePropertyAll(Colors.amber),
minimumSize: WidgetStatePropertyAll(Size.fromHeight(30))),
onPressed: () async {
// bool talkInstalled = await isKakaoTalkInstalled();
// if (talkInstalled) {
try {
OAuthToken token =
await UserApi.instance.loginWithKakaoAccount();
// TODO 서버에 토큰 올린 후, response 에 따라 회원가입 절차
return;
} catch (e) {
print('카카오톡으로 로그인 실패 $e');
// 사용자가 카카오톡 설치 후 디바이스 권한 요청 화면에서 로그인을 취소한 경우,
// 의도적인 로그인 취소로 보고 카카오계정으로 로그인 시도 없이 로그인 취소로 처리 (예: 뒤로 가기)
if (e is PlatformException && e.code == 'CANCELED') {
return;
}
}
// }
// 카카오톡 계정이 없거나, 카카오톡 설치가 되지 않았다면 웹으로 로그인
OAuthToken token = await UserApi.instance.loginWithKakaoAccount();
// TODO 서버에 토큰 올린 후, response 에 따라 회원가입 절차
},
child: Text('카카오로그인', style: const TextStyle(color: Colors.black)),
),
const SizedBox(
height: 10,
),
......
import 'package:dispatcher_test/module/remote/base_module/base_network.dart';
import 'package:dispatcher_test/module/remote/base_module/base_network_Interceptor.dart';
import 'package:dispatcher_test/module/storage/secure_storage.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:get_it/get_it.dart';
final getIt = GetIt.instance;
Future<void> dependenciesInitialized() async {
getIt.registerSingleton<SecureStorageModule>(
SecureStorageModule(
const FlutterSecureStorage(),
),
);
// base network module
getIt.registerLazySingleton<BaseNetwork>(
() => BaseNetwork(
baseRequestInterceptor: BaseRequestInterceptor(
secureStorageModule: getIt<SecureStorageModule>(),
),
),
);
}
import 'package:dio/dio.dart';
import 'package:dispatcher_test/module/remote/base_module/base_network_Interceptor.dart';
class BaseNetwork {
final Dio _dio = Dio();
final BaseRequestInterceptor baseRequestInterceptor;
BaseNetwork({
required this.baseRequestInterceptor,
}) {
_dio.options = _dioOptions();
_dio.interceptors.add(baseRequestInterceptor);
}
BaseOptions _dioOptions() {
BaseOptions opts = BaseOptions();
opts.connectTimeout = const Duration(minutes: 1);
opts.receiveTimeout = const Duration(minutes: 1);
opts.sendTimeout = const Duration(minutes: 1);
opts.baseUrl = "https://dispatcher-dev.realbyte.net/"; // TODO 개발 서버 URL
return opts;
}
Future<Response> get({
required String path,
Map<String, dynamic>? queryParameters,
}) async {
return _dio.get(path, queryParameters: queryParameters);
}
Future<Response> post({
required String path,
Map<String, dynamic>? queryParameters,
dynamic data,
}) async {
return _dio.post(path, queryParameters: queryParameters, data: data);
}
Future<Response> put({
required String path,
Map<String, dynamic>? queryParameters,
dynamic data,
}) async {
return _dio.put(path, queryParameters: queryParameters, data: data);
}
Future<Response> delete({
required String path,
Map<String, dynamic>? queryParameters,
dynamic data,
}) async {
return _dio.delete(path, queryParameters: queryParameters, data: data);
}
Future<Response> patch({
required String path,
Map<String, dynamic>? queryParameters,
dynamic data,
}) async {
return _dio.patch(path, queryParameters: queryParameters, data: data);
}
}
import 'package:dio/dio.dart';
import 'package:dispatcher_test/module/storage/secure_storage.dart';
class BaseRequestInterceptor extends Interceptor {
final SecureStorageModule secureStorageModule;
BaseRequestInterceptor({required this.secureStorageModule});
@override
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
// TODO 토큰 판별 후, accesstoken 이 만료 되었다면 refreshToken 요청 콜.
// 콜이 끝나면 해당 토큰으로 다시 set 하여 options 에 태워 보냄
// 토큰 저장은 SecureStorage 에
return super.onRequest(options, handler);
}
@override
void onError(DioException err, ErrorInterceptorHandler handler) {
// TODO 에러에 대한 처음 처리
return super.onError(err, handler);
}
@override
void onResponse(Response response, ResponseInterceptorHandler handler) {
// TODO 응답에 대한 처음 처리
return super.onResponse(response, handler);
}
}
\ No newline at end of file
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
class SecureStorageModule {
final FlutterSecureStorage storage;
SecureStorageModule(this.storage);
Future<void> write(String key, String value) async {
await storage.write(key: key, value: value);
}
Future<String> read(String key) async {
final String ret = await storage.read(key: key) ?? '';
return ret;
}
}
......@@ -6,6 +6,10 @@
#include "generated_plugin_registrant.h"
#include <flutter_secure_storage_linux/flutter_secure_storage_linux_plugin.h>
void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) flutter_secure_storage_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterSecureStorageLinuxPlugin");
flutter_secure_storage_linux_plugin_register_with_registrar(flutter_secure_storage_linux_registrar);
}
......@@ -3,6 +3,7 @@
#
list(APPEND FLUTTER_PLUGIN_LIST
flutter_secure_storage_linux
)
list(APPEND FLUTTER_FFI_PLUGIN_LIST
......
......@@ -9,7 +9,10 @@ import cloud_firestore
import firebase_core
import firebase_messaging
import flutter_local_notifications
import flutter_secure_storage_macos
import flutter_tts
import path_provider_foundation
import shared_preferences_foundation
import speech_to_text_macos
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
......@@ -17,6 +20,9 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin"))
FLTFirebaseMessagingPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseMessagingPlugin"))
FlutterLocalNotificationsPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalNotificationsPlugin"))
FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin"))
FlutterTtsPlugin.register(with: registry.registrar(forPlugin: "FlutterTtsPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
SpeechToTextMacosPlugin.register(with: registry.registrar(forPlugin: "SpeechToTextMacosPlugin"))
}
This diff is collapsed.
......@@ -42,6 +42,24 @@ dependencies:
flutter_local_notifications: ^17.2.1+2
permission_handler: ^11.3.1
firebase_messaging: ^15.0.4
kakao_flutter_sdk_user: ^1.9.5 # 카카오 로그인 API 패키지
# inversion of control(service locator)
get_it: ^7.7.0
# network
dio: ^5.5.0+1
pretty_dio_logger: ^1.4.0
fluttertoast: ^8.2.8
uuid: ^4.4.2
# secure storage
flutter_secure_storage: ^9.2.2
dependency_overrides:
js: ">=0.6.3 < 0.7.1"
dev_dependencies:
flutter_test:
sdk: flutter
......
......@@ -8,6 +8,7 @@
#include <cloud_firestore/cloud_firestore_plugin_c_api.h>
#include <firebase_core/firebase_core_plugin_c_api.h>
#include <flutter_secure_storage_windows/flutter_secure_storage_windows_plugin.h>
#include <flutter_tts/flutter_tts_plugin.h>
#include <permission_handler_windows/permission_handler_windows_plugin.h>
......@@ -16,6 +17,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
registry->GetRegistrarForPlugin("CloudFirestorePluginCApi"));
FirebaseCorePluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FirebaseCorePluginCApi"));
FlutterSecureStorageWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin"));
FlutterTtsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FlutterTtsPlugin"));
PermissionHandlerWindowsPluginRegisterWithRegistrar(
......
......@@ -5,6 +5,7 @@
list(APPEND FLUTTER_PLUGIN_LIST
cloud_firestore
firebase_core
flutter_secure_storage_windows
flutter_tts
permission_handler_windows
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment