react native gps foreground service - android, kotlin (1)

react native 에서 gps 트래킹을 해야한다. 앱이 백그라운드에 있어도 동작하도록 네이티브 모듈을 만드는 것만 해도 많이 안하다보니 까다로운데 gps + 서비스 동작을 해야한다니. 기본으로 돌아가기로 했다. 일단 안드로이드 앱에서 GPS 트래킹하는 코드부터 시도해보았다. ### MainActivity.kt ``` package com.example.gpstracker import android.annotation.SuppressLint import android.content.Context import android.content.pm.PackageManager import android.location.LocationListener import android.location.LocationManager import android.os.Bundle import android.util.Log import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.material3.Button import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.core.app.ActivityCompat import com.example.gpstracker.ui.theme.GpsTrackerTheme val T

Modularization of react NativeModules

써드파티 SDK를 붙이는데 해당 업체에서 npm package 가 아닌 각 OS의 SDK 와 react native 코드를 주면서 앱에 내장하라는 가이드를 받았다. 물론 이를 그냥 앱에 넣을 수는 없어서 package 로 분리하는 작업을 하였다. 이 작업을 하며 겪었던 트러블슈팅을 정리하고자 한다. # Android ## 자바와 코틀린간 패키지 참조 불가 build.gradle (app) 에 하단 설정 추가 ``` apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' ``` ## Could not find com.this.repo. 모듈의 example 프로젝트에서 받고자하는 sdk 라이브러리가 없다는 에러. example 프로젝트의 build.gradle 에 아래 코드를 추가하여 필요한 sdk 를 다운받을 수 있도록 한다. Can’t find module in example project, and I fixed it adding below codes in build.gradle (example) ``` allprojects { repositories{ maven { url 'https://repository.something/‘ } // change this line to download the sdk you aimed } } ``` ## Workspaces can only be enabled in private projects. 모듈을 붙이고자 하는 프로젝트는 프라이빗 프로젝트이기 때문에 npm 에 퍼블리쉬되지 않은 패키지의 경우 package.json 에 "private:true" 를 추가해야 한다. Because my project is “private:true”, If I want to add non-published package, the package should be

Operating System Concept Eng(1)

이미지
1.1 In a multi-programming and time-sharing environment, several users share the system simultaneously. This situation can result in various security problems. a. What are two such problems? Because of storage or memory resource sharing,  security is weak. Someone strangers can still or copy others' data. b. Can we ensure the same degree of security in a time-shared machine as in a dedicated machine? Explain your answer. I think, dedicated machine(like a computer for military purpose) have more external technology security plan, so we can't ensure the same degree of security in general used machines. 1.13  The issue of resource utilization shows up in different forms in different types of operating systems. List what resources must be managed carefully in the following settings: a. Mainframe or minicomputer systems Because many people connect to A computer, we have to consider fair distribution of cpu time, memory resource and I/O b. Workstations

블로거에서 마크다운 사용하기 - Markdown in Google Blooger

이미지
### Reference : https://github.com/cs905s/md-in-blogger?tab=readme-ov-file 참고한 문서가 작성된지 오래되어 따라하기 힘들어서 2024년 4월 기준으로 설명합니다. I write this document because the reference I refered is too old to follow. So I had some trouble to apply markdown in Blooger using the reference. ## 1. 마크다운을 사용할 수 있도록 스크립트 코드 추가 / Add markdown script 1. 블로거 관리자페이지 왼쪽의 테마를 누르고 나오는 테마 페이지에서 버튼 오른쪽에 있는 화살표를 누릅니다. 메뉴에서 HTML 편집이 있는데 이 버튼을 누르면 테마 HTML 편집을 할 수 있는 창이 열리고 여기서 마크다운 지원을 위한 스크립트 코드를 추가해야 합니다. In admin page, you can see theme on leftside, after clicking theme, click small arrow down icon. A menu will be released and click `Edit HTML`. You can add script code to support markdown in HTML editing page. 2. 헤드 태그를 찾아야합니다. /head 를 검색하여 `</head>` 바로 위에 하단 5줄의 스크립트 코드를 붙여넣어주세요 Find head tag. Search /head (using ctrl + f). Copy below 5 lines and paste just above of `</head>` ``` <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.9.0/highlight.min.js" type="text/javascri

카카오 내비 리엑트 네이티브 모듈 만들기 ft.코틀린

사용자를 카카오 내비로 이동시키는 기능이 최근 카카오네비 딥링크가 막혀서 더이상 사용하지 못하는 이슈가 있었습니다. 카카오 SDK 를 포팅한 React Native 모듈이 있는지 찾아보았으나 대부분은 Out-Dated 된 모듈들이어서 새로 만들기로 하였습니다. A~Z 까지 모든것을 설명하려는 것은 이 포스팅의 목적이 아니고, 개인적으로 조금 헤매었던 부분을 정리하고자 합니다. ### create react native module React Native 공식 문서에도 나와있듯 모듈을 쉽게 만들기 위해 이미 보일러 플레이트가 완성되어있는 코드를 베이스로 삼아 만들어 줍니다. ``` npx create-react-native-library@latest react-native-awesome-module ``` ### react module 에서 app context 사용 방법 SDK 문서에 따르면 사용자 기기에 카카오내비 앱의 설치 유무를 확인하기 위해서 아래와 같은 코드를 사용할 수 있습니다. ``` if (NaviClient.instance.isKakaoNaviInstalled(context)) { Log.i(TAG, "카카오내비 앱으로 길 안내 가능") } else { Log.i(TAG, "카카오내비 미설치") } ``` 하지만 안드로이드 네이티브가 아닌 우리는 리엑트 네이티브의 모듈을 가져와서 context 로 넣어주어야 하고 이는 네이티브 모듈에서 아래와 같이 잡아올 수 있습니다. ``` class KakaoNaviModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) { private var context: Context = reactContext.getApplicationContext() ``` ### modul

Transform react-native AppDelegate.mm to AppDelegate.swift

이미지
  Delete AppDelegate.h, AppDelegate.mm, main.m Make AppDelegate.swift & bridging-header Thankfully most of codes is wraped in RCTAppDelegate after RN0.71. So, as you can see, we should transform few codes from objective c to swift like below There is a you can’t just copy and paste. self.moduleName must be your ‘Project Name’ After making your own AppDelegate.swift and bridging-header, try to run using ‘npx react-native run-ios’ or ‘yarn ios’ wthatever you want. Then you can see this error.   In left, Project navigator displays, click your project > Build Settings > search ‘active com’ You can find Active Compilation Conditions. Add ‘DEBUG’ in Debug. It makes preprocessor recognize DEBUG flag. Run your application again after adding DEBUG flag. If you won’t use new architecture, this is it. To run this app suing new architecture, run the following in ios directory. bundle install && RCT_NEW_ARCH_ENABLED=1 bundle exec pod install If you run after pod install, you will

한국에서 외국인과 결혼하기 - How to get married with global girlfriend in Korea

이미지
중요: 해당 포스팅은 참고용으로 2022년 7월 15일을 기준으로 작성되었습니다. 모든 서식은 하이코리아에서 다운받으시고, 시간이 지남에 따라 작성 방식은 변경될 수 있습니다.  NOTE : All I wrote and reference here is from July 15th, 2022. You must download all the documents you need from 'Hi Korea' official website, because as time goes by how to write the documents can change. NOTE : This is for writing Marriage Registration IN KOREA  혼인신고 제가 직접 작성하면서 헷갈렸던 부분을 위주로 설명합니다. I will explain below about the parts I confused. 해당 문서는 모두! 한글 로 작성해야 합니다. 처음에 저는 아내의 이름을 외국인 등록증에 적힌 그대로 적었다가 한글로 수정해야 했어요. 증인중에 한명을 아내 친구로 했는데 증인 이름 역시 한글로 적어야 합니다. You must write everything in KOREAN. At the first time, I also wrote my wife's name in English as same as in Alien Registration Card and I fixed it in Korean. One of my witness is wife's friend. I wrote her name in English but I fixed it too. 등록기준지 는 가족관계증명서를 떼면 나옵니다. 아버지, 어머니, 본인 모두 각각 조회해봐야 해요. You can get your 등록기준지 from your Family Relations Certificate. You should check yours, your father's and your moth

이 블로그의 인기 게시물

Operating System Concept

카카오 내비 리엑트 네이티브 모듈 만들기 ft.코틀린

Operating System Concepts 9th