在 android/app/src/main/java/com/jim/notification/ 路徑,先找到 MainApplication.kt 或 MainApplication.java 檔案。
找到 getPackages(),加入自訂的 ProgressNotificationPackage class
import com.yourpackage.progressnotification.ProgressNotificationPackage
// Inside the getPackages() method:
packages.add(ProgressNotificationPackage())
// MainApplication.kt 檔案
override val reactNativeHost: ReactNativeHost = ReactNativeHostWrapper(
this,
object : DefaultReactNativeHost(this) {
override fun getPackages(): List<ReactPackage> {
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
packages.add(ProgressNotificationPackage())
return PackageList(this).packages
}
override fun getJSMainModuleName(): String = ".expo/.virtual-metro-entry"
override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG
override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED
}
)
套用模組後,接著要設置 JavaScript 端與 Module 互動,以及畫面按鈕的作動邏輯。