I am using PDFMake, library to generate PDF from my ionic/angular application. The PDF generation is working perfectly fine. However issue is that -
After pdf generation process is completed, I go back to dashboard page
And from dashboard page I go to Another page (any page, same pdf generation page or any other page), I get following error.
I have following codes:
import pdfMake from 'pdfmake/build/pdfmake';
import pdfFonts from 'pdfmake/build/vfs_fonts';
pdfMake.vfs = pdfFonts.pdfMake.vfs;
//---------------------
//---------------------
ionViewWillLeave(){
if(this.pdfObj) this.pdfObj = null;
}
generatePdf(){
let docDefinition = {
pageSize: "A3",
content: [
..............
],
}
this.pdfObj = pdfMake.createPdf(docDefinition);
this.pdfObj.download();
}
------------------------------------
Any help will be highly appreciated.
Thanks
This issue is due to pdfmake.js polyfills all promises related function and due to this all ionic promises are redirecting to those polyfiled functions
currently I'm also facing same issue for iOS devices only so I have added workaround as follows which may help you as well (Not sure with exact solution)
ionic 5
cordova 10
pdfmake 0.2.4
Related
The website that I would like to scrape
Before scraping the data I need first I must choose departure, arrival and date then I must clicked the green buton then I can reach the data I would like to scrape.
How I can perform these actions in website via Flutter. Then I will use these datas in the Flutter app.
I tried to scrape via import http.dart and parser.dart libraries but I couldn't. I am beginner in coding and Flutter.
Hey found a article which will help you do this.
Follow :
https://morioh.com/p/b7b4aa4d696e
Kudos to Morioh for the detailed step by step article.
Concern : this might be outdated package as there is no update since past one year.
You maybe need the dart:html in all app scope , but this file are limited on the web (or You need to do something different on the web than on an Android device!).
you can create 3 file and to handle this mode.
file web.dart :
import 'dart:html' as html;
void webScrap() {
// blablabla webScrap in web
}
String cookie = "";
file native.dart :
void webScrap() {
// blablabla webScrap in native
}
String cookie = "";
file switch_native_web.dart :
import 'native.dart' if (dart.library.html) 'web.dart' as switch_value;
class SwitchNativeWeb {
static String cookie = switch_value.cookie;
static void webScrap() {
switch_value.webScrap();
}
}
But i suggest to you , see this example for web scraping in flutter .
Gist full Snippets: Gist.Github.com
Repository : Github.com
Just over a year ago I created a chatbot using IBM Watson Assistant. It is successfully interfacing with wordpress and facebook. it was working perfectly well in a web page too, but has now stopped outputting any text. I created the website integration by copying the code shown in the "preview link" page created by IBM when the bot is under development. That code includes a library file called "chat.0.0.4.js" and corresponding css. When the code runs now, the chatbot renders correctly, but when I look at the browser console I see at line 12990 in chat.0.0.4.js:
400 - {"error":"Invalid Request Body","errors":[{"message":"When source.type is not 'watson', source.id is required
Does anyone know how to fix this? I see that the integration code from the "preview link" is now totally different and I wonder if the mechanism I used a year ago is now depreciated?
Thanks.
I think you need to use the newer version, the script to integrate WA has changed and now looks like this:
<script>
window.watsonAssistantChatOptions = {
integrationID: 'YOUR_INTEGRATION_ID',
region: 'YOUR_REGION',
serviceInstanceID: 'YOUR_SERVICE_INSTANCE',
onLoad: function(instance) {
instance.updateUserID(L12345);
instance.render();
}
};
setTimeout(function(){
const t=document.createElement('script');
t.src="https://web-chat.global.assistant.watson.appdomain.cloud/loadWatsonAssistantChat.js";
document.head.appendChild(t);
});
</script>
I am trying to print external link into ionic app using ionic printer plugin
https://ionicframework.com/docs/native/printer/
printticket(){
let printurl = "http://www.gmail.com";
let options: PrintOptions = {
name: 'Waridi Events',
duplex: true,
landscape: false,
grayscale: false
};
this.printer.print(printurl, options).then(onSuccess=>{
console.log("Done =>" + onSuccess);
}, onError=>{
console.log("Error=>"+onError);
});
}
This is working on android but not working on ios. Please give me some better way to print.
sometimes it is working
And sometimes failed to load data
Finally I got the solution using api call.
Before call the print call the api from the link and get the html codes and save all into a variable and print it.
When developing with Ionic 2 how does one stay on the current page when making code changes? In Ionic 1 livereload would take you back to your current url - however in ionic 2 there are no urls.
Is there a setting that will make livereload keep me on the current page?
I'm open to enabling URLs as well if that's what it takes to not have to manually navigate back to my page on every code change. However I haven't been able to find how to do that in the v2 docs yet.
To stop live reloading in Ionic2 following changes I have done in the configurations file : ionic.config.js.
In ionic.config.js
watch: {
sass: ['app/**/*.scss'],
html: ['app/**/*.html'],
livereload: [
'www/build/**/*.html',
'www/build/**/*.js',
'www/build/**/*.css'
]
}
above section edited to :
watch: {
sass: ['app/**/*.scss'],
html: ['app/**/*.html'],
}
Then stopped ionic serve by q, and again started. Auto refreshing got stopped, we have to manually refresh to reflect the latest changes.
You could set the this.rootPage in your app.component.ts to the page you are working on. I often do this if i am working on say the foobar.ts page for a while ill change it to
this.rootPage = FooBar;
And then change it back to the default root page when i am done.
Actually ionic.config.js has been deprecated . So i found a way may , go to this node_modules\#ionic\app-scripts\config . Change in file called watch.js
srcFiles: {
paths: ['{{SRC}}/**/*.(ts|html|s(c|a)ss)'],
options: { ignored: ['{{SRC}}/**/*.spec.ts', '{{SRC}}/**/*.e2e.ts', '**/*.DS_Store'] },
callback: watch.buildUpdate
},
No, there is no way to do what you are asking for, because ionic 2 is not using urls. Actually they are handling the pages as a variable on window, so when you or the live reload refresh the page it will go to the initial state. By the way actually there are no plans for implement the angular router, let's wait until the RC, maybe they would like to implement it
I am working on login with google functionality with $cordovaOauth.google plugin. But I am getting unsupported_response_type error.
$cordovaOauth.google("MY_APP_ID", ["https://www.googleapis.com/auth/urlshortener", "https://www.googleapis.com/auth/userinfo.email"]).then(function (result) {
console.log(JSON.stringify(result));
alert(JSON.stringify(result));
$scope.gdata = result;
}, function (error) {
console.log(error);
});
Where I am making mistake !?
Yes because $cordovaOauth plugin loading webview so you must need web clientID from Google API. And that will not work for ionic ( Mobile app ) so you need to do following things.
First
You need to use schema for your app to give internal URL like google:// or twitter://
Reference : http://mcgivery.com/using-custom-url-schemes-ionic-framework-app/
and provide that custom URL in Google redirect url ( This is not working all time as Google not accept custom URL but you can give it a try ).
Second and Working solution :
You need to create Google app with your app identifier and keytool.
For Android :
https://developers.google.com/identity/sign-in/android/start follow step second and provide your app name and unique identifier ( i.e dipesh.cool.com )
For iOS :
https://developers.google.com/mobile/add?platform=ios&cntapi=signin
same information as mentioned for android.
Then you need to get REVERSED_CLIENT_ID value from the config file which download will be available once you are done with above two steps ( you can grab it from iOS config file it is easy to find from that file ).
And then simply run below command and code and you will have all working.
Command :
cordova plugin add cordova-plugin-googleplus --variable REVERSED_CLIENT_ID=GRAB_THIS_FROM_IOS_OR_ANDROID_CONFIG_FILE
Angular code :
$scope.GoogleLogin = function()
{
$scope.loaderShow('Google');
window.plugins.googleplus.login({},function (obj)
{
window.localStorage.setItem('signin', 'Google');
window.localStorage.setItem('g_uid', obj.userId);
window.localStorage.setItem('g_fname', obj.givenName);
window.localStorage.setItem('g_lname', obj.familyName);
window.localStorage.setItem('user_full_name', obj.displayName);
window.localStorage.setItem('g_email', obj.email);
window.localStorage.setItem('gotPdetails', 'false');
$scope.loaderHide();
$state.go('app.dashboard');
},
function (msg)
{
$scope.showAlert('Google signin Error<br/>'+msg);
$scope.loaderHide();
});
}