- CardNotifListenerService: 결제 알림(금액+승인/결제/카드) 가로채 백엔드로 전송 (토큰은 Capacitor Preferences에서, 결제성 알림만 전송) - CardNotifPlugin: 알림 접근 권한 확인/설정 열기 - AndroidManifest 서비스 등록, MainActivity 플러그인 등록 - 가계부 화면: 네이티브 미허용 시 '알림 접근 권한' 안내 배너 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package kr.sblog.slimbudget;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.provider.Settings;
|
||||
|
||||
import com.getcapacitor.JSObject;
|
||||
import com.getcapacitor.Plugin;
|
||||
import com.getcapacitor.PluginCall;
|
||||
import com.getcapacitor.PluginMethod;
|
||||
import com.getcapacitor.annotation.CapacitorPlugin;
|
||||
|
||||
/**
|
||||
* 카드 결제 알림 자동인식 플러그인.
|
||||
* - isEnabled: 알림 접근 권한(NotificationListener) 허용 여부
|
||||
* - openSettings: 알림 접근 설정 화면 열기
|
||||
* 실제 알림 수신/전송은 CardNotifListenerService 가 담당한다.
|
||||
*/
|
||||
@CapacitorPlugin(name = "CardNotif")
|
||||
public class CardNotifPlugin extends Plugin {
|
||||
|
||||
@PluginMethod
|
||||
public void isEnabled(PluginCall call) {
|
||||
String pkg = getContext().getPackageName();
|
||||
String flat = Settings.Secure.getString(
|
||||
getContext().getContentResolver(), "enabled_notification_listeners");
|
||||
boolean enabled = flat != null && flat.contains(pkg);
|
||||
JSObject ret = new JSObject();
|
||||
ret.put("enabled", enabled);
|
||||
call.resolve(ret);
|
||||
}
|
||||
|
||||
@PluginMethod
|
||||
public void openSettings(PluginCall call) {
|
||||
Intent intent = new Intent(Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
getContext().startActivity(intent);
|
||||
call.resolve();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user