-
-
Notifications
You must be signed in to change notification settings - Fork 40
Webpack bundled app can't find modules when app is closed to run as a background service #952
Description
This is app runs when built in legacy it uses a background service to receive massages and other real-time content, but when bundled and the app is closed app crashes, it can't find modules required in NotificatinIntentService! I asked here at SO https://stackoverflow.com/questions/56777821/webpack-bundle-cant-find-a-module-when-in-background ,Error: com.tns.NativeScriptException: Failed to find module: "../db", relative to: app/notifications/
this is NotificationIntentService.js
tried changing relative paths it doesn't work!
this is NotificationIntentService.js where it requires the modules needed for background communication(real time notifications and messages)
onHandleIntent: function (intent) {
var action = intent.getAction();
if ("ACTION_START" == action) {
processStartNotification();
}
android.support.v4.content.WakefulBroadcastReceiver.completeWakefulIntent(intent);
}
});
const db=require("../db")
var LocalNotifications_1= require("nativescript-local-notifications");
var Vibrate = require("nativescript-vibrate").Vibrate;
var vibrator = new Vibrate();
var color_1 = require('tns-core-modules/color');
var dialogs_1 = require("tns-core-modules/ui/dialogs");
var model=require("../view");
var frameModule = require("tns-core-modules/ui/frame");
model.checkStatus()
var io=require('../connection').io;
var iD=0
function processStartNotification() {
// Do something. For example, fetch fresh data from backend to create a rich notification?
var utils = require("tns-core-modules/utils/utils");
var context = utils.ad.getApplicationContext();
var ID=0;
}
function getDeleteIntent(context) {
var intent = new android.content.Intent(context, com.tns.broadcastreceivers.NotificationEventReceiver.class);
intent.setAction("ACTION_DELETE_NOTIFICATION");
return android.app.PendingIntent.getBroadcast(context, 0, intent, android.app.PendingIntent.FLAG_UPDATE_CURRENT);
}
It seems after bundling paths can't be resolved while in background all others work while app is 'live'
Replicate
Create an app with a background service that requires modules like database, connection to server , when closed app set's an alarm service firing every 5 min, it shouldn't error.
I tried changing relative paths