fix(android): resolve DailyNotification plugin registration issue

- Move plugin registration before super.onCreate() in MainActivity
- Create dedicated dailynotification module for proper plugin structure
- Add comprehensive logging for plugin registration debugging
- Update Vue components with enhanced plugin detection and logging
- Fix TypeScript errors in HomeView.vue for proper build

The plugin was not being loaded because registration happened after
BridgeActivity initialization. Moving registerPlugin() before super.onCreate()
ensures the plugin is available when Capacitor loads plugins.

Resolves simplified status dialog issue by ensuring native plugin
is properly registered and accessible to JavaScript layer.
This commit is contained in:
Matthew Raymer
2025-10-17 08:06:53 +00:00
parent 80a268ffdc
commit 64b65f8a94
8 changed files with 229 additions and 44 deletions

View File

@@ -16,6 +16,10 @@ android {
ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
buildTypes {
release {
minifyEnabled false
@@ -40,6 +44,7 @@ dependencies {
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
implementation project(':capacitor-cordova-android-plugins')
implementation project(':dailynotification')
}
apply from: 'capacitor.build.gradle'

View File

@@ -1,5 +1,24 @@
package com.timesafari.dailynotification.test;
import com.getcapacitor.BridgeActivity;
import com.timesafari.dailynotification.DailyNotificationPlugin;
public class MainActivity extends BridgeActivity {}
public class MainActivity extends BridgeActivity {
@Override
public void onCreate(android.os.Bundle savedInstanceState) {
android.util.Log.d("MainActivity", "MainActivity.onCreate() called - START");
// Register the DailyNotification plugin BEFORE calling super.onCreate()
android.util.Log.d("MainActivity", "Registering DailyNotification plugin...");
try {
registerPlugin(DailyNotificationPlugin.class);
android.util.Log.d("MainActivity", "DailyNotification plugin registered successfully");
} catch (Exception e) {
android.util.Log.e("MainActivity", "Failed to register DailyNotification plugin", e);
}
super.onCreate(savedInstanceState);
android.util.Log.d("MainActivity", "MainActivity.onCreate() - after super.onCreate()");
android.util.Log.d("MainActivity", "MainActivity.onCreate() called - END");
}
}

View File

@@ -0,0 +1,22 @@
apply plugin: 'com.android.library'
android {
namespace "com.timesafari.dailynotification"
compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
}
dependencies {
implementation project(':capacitor-android')
}

View File

@@ -0,0 +1,6 @@
[
{
"name": "DailyNotification",
"classpath": "com.timesafari.dailynotification.DailyNotificationPlugin"
}
]

View File

@@ -1,4 +1,4 @@
package com.timesafari.dailynotification.test;
package com.timesafari.dailynotification;
import com.getcapacitor.JSObject;
import com.getcapacitor.Plugin;
@@ -13,6 +13,7 @@ public class DailyNotificationPlugin extends Plugin {
public void load() {
super.load();
// Log that the plugin has loaded
android.util.Log.d("DailyNotificationPlugin", "Plugin load() method called");
System.out.println("DN|PLUGIN_LOAD_START");
}

View File

@@ -1,4 +1,5 @@
include ':app'
include ':dailynotification'
include ':capacitor-cordova-android-plugins'
project(':capacitor-cordova-android-plugins').projectDir = new File('./capacitor-cordova-android-plugins/')