Push notification (#536)

* add push notification feature

* merge new app impl

* change dsc key

* import

* reverse mock dsc

* worked in the ios

* checked in android

* update url and delete console

* delete small changes

* lint

* add yarn.lock

* fix warning message

* add mock notification service for test code

* fix path for the mock implementation

* add mock deeplink to the test code

* nice notificationServiceMock.js

* delete unused firebase related implementation

* fix wording and UI related to notification service

* hotfix on mockdatascreen

---------

Co-authored-by: turnoffthiscomputer <colin.remi07@gmail.com>
This commit is contained in:
nicoshark
2025-05-16 06:46:21 +09:00
committed by GitHub
parent 2bedf095b7
commit 3db25aa469
41 changed files with 8031 additions and 4791 deletions

View File

@@ -2,6 +2,7 @@ apply plugin: "com.android.application"
apply plugin: "com.facebook.react"
apply plugin: "org.jetbrains.kotlin.android"
apply plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services'
/**
@@ -142,6 +143,10 @@ dependencies {
implementation 'com.github.blikoon:QRCodeScanner:0.1.2'
// Firebase Dependencies
implementation platform('com.google.firebase:firebase-bom:32.7.3')
implementation 'com.google.firebase:firebase-messaging'
if (hermesEnabled.toBoolean()) {
implementation("com.facebook.react:hermes-android")
} else {

View File

@@ -0,0 +1,29 @@
{
"project_info": {
"project_number": "260578412566",
"project_id": "selfxyz-app",
"storage_bucket": "selfxyz-app.firebasestorage.app"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:260578412566:android:c52d3f8e947a7a90c78d37",
"android_client_info": {
"package_name": "com.proofofpassportapp"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyDbMZ52EpHA-5BbMgTQK3OMOVcarGJQ-es"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": []
}
}
}
],
"configuration_version": "1"
}

View File

@@ -7,11 +7,10 @@
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.NFC" />
<uses-permission android:name="android.permission.VIBRATE"/>
<application
android:usesCleartextTraffic="true"
tools:targetApi="28"
tools:ignore="GoogleAppIndexingWarning"
/>
</manifest>

View File

@@ -1,14 +1,16 @@
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.ACCESS_SURFACE_FLINGER" />
<uses-permission android:name="android.permission.NFC" />
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:name=".MainApplication"
android:largeHeap="true"
@@ -34,7 +36,7 @@
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT"/>
@@ -48,5 +50,27 @@
android:name="android.nfc.action.TECH_DISCOVERED"
android:resource="@xml/nfc_tech_filter" />
</activity>
<service
android:name="com.google.firebase.messaging.FirebaseMessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="@string/default_notification_channel_id"
tools:replace="android:value" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@mipmap/ic_launcher" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@color/notification_color"
tools:replace="android:resource" />
</application>
</manifest>

View File

@@ -1,6 +1,10 @@
package com.proofofpassportapp
import android.app.Application
import android.app.NotificationChannel
import android.app.NotificationManager
import android.content.Context
import android.os.Build
import com.facebook.react.PackageList
import com.facebook.react.ReactApplication
import com.facebook.react.ReactNativeHost
@@ -38,5 +42,20 @@ class MainApplication : Application(), ReactApplication {
DefaultNewArchitectureEntryPoint.load()
}
// ReactNativeFlipper.initializeFlipper(this, reactNativeHost.reactInstanceManager)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val channel = NotificationChannel(
"default",
"Default Channel",
NotificationManager.IMPORTANCE_HIGH
).apply {
description = "Default notification channel"
enableLights(true)
enableVibration(true)
}
val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
notificationManager.createNotificationChannel(channel)
}
}
}

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="notification_color">#000000</color>
</resources>

View File

@@ -1,3 +1,5 @@
<resources>
<string name="app_name">Self</string>
<string name="default_notification_channel_id">self_notifications</string>
<string name="default_notification_channel_name">Self Notifications</string>
</resources>

View File

@@ -8,6 +8,8 @@ buildscript {
targetSdkVersion = 35
ndkVersion = "26.1.10909125"
kotlinVersion = "1.9.24"
firebaseMessagingVersion = "23.4.0"
firebaseBomVersion = "32.7.3"
}
repositories {
google()
@@ -17,6 +19,7 @@ buildscript {
}
}
dependencies {
classpath("com.android.tools.build:gradle:7.3.1")
classpath("com.facebook.react:react-native-gradle-plugin")
// classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
@@ -24,6 +27,8 @@ buildscript {
classpath 'com.google.gms:google-services:4.3.14'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.2'
classpath 'org.mozilla.rust-android-gradle:plugin:0.9.3'
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0")
classpath("com.google.gms:google-services:4.4.0")
}
}
@@ -31,8 +36,17 @@ allprojects {
repositories {
google()
mavenCentral()
maven { url "https://jitpack.io" }
maven {
url("$rootDir/../node_modules/react-native/android")
}
maven {
url("$rootDir/../node_modules/jsc-android/dist")
}
maven { url 'https://jitpack.io' }
jcenter()
maven {
url 'https://google.bintray.com/google-services'
}
}
configurations.configureEach {
resolutionStrategy.dependencySubstitution {
@@ -41,6 +55,11 @@ allprojects {
}
resolutionStrategy.force 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
}
configurations.all {
resolutionStrategy {
force 'com.google.firebase:firebase-iid:21.1.0'
}
}
}
subprojects {
@@ -49,7 +68,7 @@ subprojects {
android {
def manifestFile = project.file('src/main/AndroidManifest.xml')
def buildGradleFile = project.file('build.gradle')
if (buildGradleFile.exists()) {
def buildGradleText = buildGradleFile.text
def namespaceMatcher = buildGradleText =~ /namespace\s*['"](.+?)['"]/
@@ -59,7 +78,7 @@ subprojects {
return
}
}
if (manifestFile.exists()) {
def manifestText = manifestFile.text
def packageMatcher = manifestText =~ /package="([\w\.]+)"/

View File

@@ -43,4 +43,4 @@ newArchEnabled=false
# If set to false, you will be using JSC instead.
hermesEnabled=true
android.jetifier.ignorelist=bcprov-jdk18on
android.jetifier.ignorelist=bcprov-jdk18on