For an ionic 2 app to print using Sunmi V1, added native plugin for printer by executing
cordova plugin add cordova-plugin-printer
First I checked whether the printer is available by
checkPrinter() {
this.printer.check().then(function () {
alert("Printer available");
}, function () {
alert("Printer not available");
});
}
It alerts "Printer available"
But the below method doesn't prompt any message
printData() {
this.printer.isAvailable().then(function () {
this.printer.print("Test Data").then(function () {
alert("Printed");
}, function () {
alert("Printing error");
});
}, function () {
alert('Unavailable');
});
}
So I called Printer.print method directly as below
printData(){
this.printer.print("Test Data").then(function () {
alert("Printed");
}, function () {
alert("Printing Error");
});
}
This method opens Print dialog to choose printer
If I select 'All Printers' from the dropdown to select printer instead of 'Save as PDF', then the search screen appears and keeps on searching...
Is some configuration missing or is it possible to interact with POS printers using cordova printer plugin?
Thanks.
i found a new plugin created by labibramadhan. Thanks labib
you can find the plugin here
https://github.com/labibramadhan/cordova-sunmi-inner-printer
First, install by typing ionic
cordova plugin add https://github.com/labibramadhan/cordova-sunmi-inner-printer.git
Then, use it on your cordova javascript codes by calling:
window.sunmiInnerPrinter.printOriginalText("Hello World!")
window.sunmiInnerPrinter.[methods available on here]
https://github.com/labibramadhan/cordova-sunmi-inner-printer/blob/master/www/innerprinter.js
Thank you
"Sunmi printer itself is not a network printer, web applications can not communicate directly with the printer, you need to accept data on the android applications" - From the documents available in their site. (I also contacted their support team but there was no proper reply)
As of now it doesn't support, so I am using github.com/shangmisunmi/SunmiPrinterDemo as example and developing the application in Android instead of ionic 2.
According to the documentation is not that easy:
http://docs.sunmi.com/htmls/index.html?lang=en##V1%20Docs%20&%20Resources
Related
I am using react-native-fbsdk for login in react-native app. after all setup , I am getting some error.
code I used for login action
facebook = () => {
console.log("LoginManager ", LoginManager);
console.log("Login ", LoginManager.logInWithReadPermissions);
LoginManager.logInWithReadPermissions([
"public_profile"
]).then(result => {
if (result.isCancelled) {
console.log("Login cancelled");
} else {
console.log(
"Login success with permissions",
result.grantedPermissions.toString()
);
}
});
};
now here is my console output 1 :
LoginManager
Object {logInWithReadPermissions: function, logInWithPublishPermissions: function, getLoginBehavior: function, setLoginBehavior: function, getDefaultAudience: function…}
getDefaultAudience
:
function getDefaultAudience()
getLoginBehavior
:
function getLoginBehavior()
logInWithPublishPermissions
:
function logInWithPublishPermissions(permissions)
logInWithReadPermissions
:
function logInWithReadPermissions(permissions)
logOut
:
function logOut()
setDefaultAudience
:
function setDefaultAudience(defaultAudience)
setLoginBehavior
:
function setLoginBehavior(loginBehavior)
now here is my console output 2 :
function logInWithReadPermissions(permissions) {
return LoginManager.logInWithReadPermissions(permissions);
}
Error :
Cannot read property 'logInWithReadPermissions' of undefined
what is missing here not able to get .
might you can follow this video tutorial about iOs + Facebook Configuration.
Also you can review the command react-native link to link well the FBSDK libraries.
Hope that my answer helps you.
Are you using Android or iOS? Chances are that you haven't properly linked the Facebook SDK for the mobile platform that you're using.
For Android you should ensure that you have completed all the steps in the quickstart here: https://developers.facebook.com/quickstarts/?platform=android
For iOS, check through the Troubleshooting section here: https://developers.facebook.com/docs/react-native/configure-ios
You might actually find an error in your logs during the compile phase or when your app has just started running.
Iam little bit late to the party but use loginWithPermissions instead.
the other two methods are deprecated (loginWithReadPermissions,
loginWithPublishPermissions)
for in instance:
var result = await LoginManager.logInWithPermissions(scope)
with fbsdk version:
"react-native-fbsdk": "1.0.1"
dont forget to run yarn install if you change versions in package.json
I am trying to test printing functionality in an app. Am using katzer/cordova-plugin-printer.
I created a button that calls the printer, below is the code I wrote, not sure if its correct:
print(){
Printer.isAvailable().then(
()=>{
Printer.print("<h2>This is just a sample!</h2>").then(
()=>alert('Printing successfull'),
()=>{alert('Unable to print')}
);
},
(reason)=>{
alert('no printer found');
alert(reason)
});
}
I am using an android phone to test
you need to apply the printoptions with an document name.
Printer.print("<h2>This is just a sample!</h2>", { name: 'testdoc' })
This is a weird issue, that is some what hard to generate and explore.
While building a web-app using Angular, my boss found that all the buttons on the app that are using ng-click directive are not working.
Now, this issue only happens on iphone 6 with IOS 8.3 and using the safari browser.
I can say that when was tested on iPhone5 (All versions), iPhone 6 (IOS 9), Safari for windows and all other browsers (Mobile and desktop), ng-click works like a charm.
The app is being build using Angular 1.4.3.
This is the code for the button, as you can see, nothing special about it:
<button class="btn calculate-button" ng-click="onCalculate()">Calculate</button>
And in the controller:
$scope.onCalculate = function () {
//Do something... And then:
$state.go('someplace');
};
I tried many changes that were suggested here, including ng-touch, ng-bind, building my own click directive as follows:
.directive('basicClick', function($parse, $rootScope) {
return {
compile: function(elem, attr) {
var fn = $parse(attr.basicClick);
return function(scope, elem) {
elem.on('click', function(e) {
fn(scope, {$event: e});
scope.$apply();
});
};
}
};
});
Couldn't find any proper solution for the problem.
Thanks.
IOS 8.4.1 Update has a known issue which stop ng-link and ng-click to work.
Using "touchstart click" can possibly solve this issue.
app.directive("ngMobileClick", [function () {
return function (scope, elem, attrs) {
elem.bind("touchstart click", function (e) {
e.preventDefault();
e.stopPropagation();
scope.$apply(attrs["ngMobileClick"]);
});
}
}])
HTML call: ng-mobile-click="onCalculate()"
I fixed it in the end.
The problem was in the //Do something... And then: part of the function.
At some point along the way, that function saves some data to the browser local storage.
My boss was using private browsing on safari, and apparently when using private browsing on safari, the browser wont save and data on the local storage and it throws an exception and kills the code.
Well, thanks any way.
I have a requirement for a popup to appear with a custom heading (having it appear from index.html on an app just looks tacky).
I tried the suggestion at the end of the following link:
Custom JavaScript alerts in iOS using PhoneGap HTML
So I added the code below to my index.html in the script section:
function showMessage(message, callback, title, buttonName){
title = title || "default title";
buttonName = buttonName || 'OK';
if(navigator.notification && navigator.notification.alert){
navigator.notification.alert(
message, // message
callback, // callback
title, // title
buttonName // buttonName
);
}else{
alert(message);
callback();
}
}
UPDATE
I have the following code for the alert;
if ((inputNumber>maxAllowed))
{
showMessage("The input is too high.",null,"Warning","Warning");
}
After compiling the app, this is not working.
The following is in index.html:
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
// Now safe to use the PhoneGap API
}
<function shown above is here>
Any idea why this is still not working? Showing from index.html
Thank you.
Kind Regards,
Gary Shergill
This error tells you that function navigator.notification don't exist.
Usually this is because:
Phonegap/Cordova is not initialized inside a HEAD
Function is not initialized inside a deviceready event. Basically function can't be called before cordova.js is fully initialized.
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
// Now safe to use the PhoneGap API
}
Here is a function I use while testing Phonegap applications on my PC. I remove it when deploying app on mobile device. It's for confirm function, but you can adjust it for alerting and so on.
// TODO: remove on deploy
navigator.notification = {
confirm: function (message, successCallback) {
successCallback(1);
}
};
You are testing in a browser so navigator.notification is undefined. Also It seems that you added the function showMessage but you are not using it. Try with:
showMessage("The value is too high!", null,"Warning", "Warning");
From phone, notice that the callback is not a string. So in your function, you pass it a string and that is causing it a problem.
http://docs.phonegap.com/en/1.0.0/phonegap_notification_notification.md.html
navigator.notification.alert(
'You are the winner!', // message
alertDismissed, // callback
'Game Over', // title
'Done' // buttonName
);
I see this is the case because I am trying to do this also. So unfortunately you cannot override the callback, and you need to "hard Code" it.
I have add the plugin using CLI like :
$ cordova plugin add cordova-plugin-dialogs
and its working fine for me.
I'm developing an app using Worklight 5.0.6. The app is targeted at tablets (iOS, Android and Windows). The app works fine on iOS and Android, but I'm having trouble getting it to run properly on Windows 8. The app crashes when I click on a link. Here's part of the error message:
"HTML1701: Unable to add dynamic content ' <link/><table></table><a href='/a'>a</a><input type='checkbox'/>'. A script attempted to inject dynamic content or elements previously modified dynamically that might be unsafe. For example, using the innerHTML property to add script or malformed HTML will generate this exception. Use the toStaticHTML method to filter dynamic content or explicitly create elements and attributes with a method such as createElement. For more information, see http://go.microsoft.com/fwlink/?LinkID=247104."
The app is supposed to inject a html fragment when a link is clicked. I'm using the following the following functions to inject html into an element:
function loadPartial(path, elementId)
{
$.get(path, function (data) {
$(elementId).html(data).trigger("create");
$("#my-navbar > ul").removeClass("ui-grid-a");
if (!hideDuringFocus)
{
$("[data-role=header]").fixedtoolbar({ hideDuringFocus: "" });
$("[data-role=footer]").fixedtoolbar({ hideDuringFocus: "" });
}
});
}
function loadPartialWithFunction(path, elementId, aFunction)
{
$.get(path, function (data) {
$(elementId).html(data).trigger("create");
$("#my-navbar > ul").removeClass("ui-grid-a");
if (!hideDuringFocus)
{
$("[data-role=header]").fixedtoolbar({ hideDuringFocus: "" });
$("[data-role=footer]").fixedtoolbar({ hideDuringFocus: "" });
}
aFunction();
});
}
Is there a mistake I made in the code? Any help would be appreciated. Please let me know if more information or source code is needed.
The issue has been resolved, thanks. I have to wrap the code with MSApp.execUnsafeLocalFunction so it'll look this:
function loadPartialWithFunction(path, elementId, aFunction)
{
$.get(path, function (data) {
MSApp.execUnsafeLocalFunction(function(){
$(elementId).html(data).trigger("create");
$("#my-navbar > ul").removeClass("ui-grid-a");
if (!hideDuringFocus)
{
$("[data-role=header]").fixedtoolbar({ hideDuringFocus: "" });
$("[data-role=footer]").fixedtoolbar({ hideDuringFocus: "" });
}
aFunction();
});
});
}
This is an issue with jQuery on Win8 Metro. Metro apps have dynamic content restrictions, that need to be bypassed first. Here is a stack overflow question with lots of answers for this issue:
Using jQuery with Windows 8 Metro JavaScript App causes security error