JavaScript Logs for iOS 14.6 are not getting captured but working for Android 10
Opened this issue · 2 comments
Hi Olivier,
First of all many thanks for this solution!!! It was a life saver.
I used the plugin in my Android Cordova App and was able to get the JavaScript Logs of my app without any issue (I installed the App on my Android 10 Mobile). But when I installed the iOS version (I am using iOS 14.6 iPad) of the App with the same app code, I could not see the JavaScript logs generated from the app. I got the following log only:
2021-08-04 14:40:13.382 Neptune D[36066:5497518] [CDVTimer][nativelogs] 0.438929ms
2021-08-04 14:40:13.386 Neptune D[36066:5497518] [CDVTimer][file] 1.182914ms
2021-08-04 14:40:13.386 Neptune D[36066:5497518] [CDVTimer][inappbrowser] 0.048995ms
2021-08-04 14:40:13.387 Neptune D[36066:5497518] [CDVTimer][statusbar] 1.018047ms
2021-08-04 14:40:13.387 Neptune D[36066:5497518] [CDVTimer][TotalPluginStartup] 8.111954ms
2021-08-04 14:40:13.452 Neptune D[36066:5497518] IAB.close() called but it was already closed.
2021-08-04 14:40:19.301 Neptune D[36066:5497518] THREAD WARNING: ['InAppBrowser'] took '14.944092' ms. Plugin should use a background thread.
2021-08-04 14:40:19.343 Neptune D[36066:5497518] No
2021-08-04 14:40:19.347 Neptune D[36066:5497518] didStartProvisionalNavigation
2021-08-04 14:40:19.830 Neptune D[36066:5497518] Unbalanced calls to begin/end appearance transitions for <UIViewController: 0x102c2a630>.
Can you please help me on this?
Thanks and Regards,
Sushant
Thanks for your kind feedback.
I've tested the plugin with the latest iOS version, and it works fine for me.
Please note that once the plugin has started, the logs are no more captured by the XCode console : you need to display them within your app using a custom page/logger (via the getLog function)
Hope it helps
Hi Olivier,
Thanks for your reply. What I have done in my App is I have a button called "Send Logs as Email" and when the button is clicked, the NativeLogs.getLog() function is called. In the callback function of the "getLog()" method I have written code to captune the "_logs" variable which should contains all the XCode logs along with the JavaScript console logs and I am using another plugin cordova-plugin-email-composer" to send the logs as a text attachment in the email.
For now I have kept the above logic platform agnostic and it runs for both Android and iOS. The logic is working perfectly for Android platform and I am getting the chromium JavaScript console logs as well. But unfortunately it is not working of the iOS Platform App. Below is the code which I have used to call the "getLog" function of the plugin:
if(typeof cordova !== "undefined"){
// Handling code for Mobile/Tablet Devices whcih will have the Native Log and Email Composer Functionality
// with Text Attachment having Native App Logs
var logs = [];
if(typeof NativeLogs !== "undefined"){
NativeLogs.getLog(5000,false, function(_logs) { // Fetch the last 5000 lines from the App Log
// do something w/ the logs
if(_logs !== ""){
logs.push(_logs.toString());
if(logs.length <= 0){
logs.push("There are no logs");
}
var logFileTxt = "";
logs.forEach( log => {
logFileTxt += log ;
logFileTxt = logFileTxt + "\r\n";
} );
if(logs.length <= 0){
logs.push("There are no logs");
}
if(typeof cordova.plugins.email !== "undefined"){
var logBlob = new Blob([logFileTxt], {type: "text/plain;charset=utf-8"});
var reader = new FileReader();
reader.readAsDataURL(logBlob);
reader.onloadend = function() {
var base64data = reader.result;
var fileData = base64data.split(",");
var base64FileData = "base64:AppLogs.txt//" + fileData[1];
cordova.plugins.email.open({
subject: 'Export App Log',
attachments: [base64FileData]
});
}
}
}
});
}
}
Thanks and Regards,
Sushant