I was wondering if there was any way to develop while using these features. Am I going to have to keep resubmitting my app over and over to test these device features? Also, I can't tell if the BarCode Scanner even opens, let alone if I were to try to get data from a QR Code.
I would like to start using more of the services you have developed, I just don't know how to work with them in the developer portal.
Thanks
Am I going to have to keep resubmitting my app over and over to test these device features?
No, you can utilize the BuildFire previewer app to test your code on an actual device. Just download the BuildFire previewer app from the App Store or Google Play Store.
I can't tell if the BarCode Scanner even opens, let alone if I were to try to get data from a QR Code.
The BuildFire SDK Wiki covers how to use the barcode scanning services. You can test your code using the Plugin Tester, which is part of the BuildFire SDK. If you need to test on an actual device, just use the BuildFire previewer, as mentioned above.
Here's sample code for calling the scanner API. The callback will either have a result or an error, to indicate success or failure.
buildfire.services.camera.barcodeScanner.scan(
{
preferFrontCamera : true,
showFlipCameraButton : true,
formats : "QR_CODE,PDF_417", // default: all but PDF_417 and RSS_EXPANDED
},
function (result, err) {
buildfire.notifications.alert("We got a barcode\n" +
"Result: " + result.text + "\n" +
"Format: " + result.format + "\n" +
"Cancelled: " + result.cancelled);
}
);
Related
I have an issue over Google OAuth and Chrome Web Store APis.
Some context before starting with the tech stuff.
I have a popular Chrome Extension that delivers in-app purchases: purchasing an item the extension goes "pro", so usage limits are expanded.
Last year the audience asked me to make a porting on Firefox (thanks to the newly available WebExtentions APIs), and I started delivering both versions.
The Firefox version does not support in-app purchase at this moment, but people are starting to ask for it (let's think the FF version as an alpha version, so not all features are guarantee to be supported).
Problem: That said, I don't want to implement a secondary payment service using Google Pay APIs or other similar APIs and I'd like that if a user makes an in-app purchase on Chrome, it is delivered on FF as well.
Hoped Solution: I thought it would have been easy to use the Google Chrome Web Store APIs. Making an user authorising its Google Account from the FF add-on I could understand if it was a paying user or not, thus enabling or disabling the "pro" limits.
Here are the steps I did.
Step 1 - Create a new app on the Google Cloud Console (I already have the one used on the Chrome Extension):
And enable the Chrome Web Store APIs:
Step 2 - Jump on Firefox JS console (inside the Options page of the add-on, so I have all the WebExtensions APIs enabled), and call the method to get a valid token (the code is quick and dirty, not enhanced and written just as a POC):
var scopes = ['https://www.googleapis.com/auth/plus.login',
'https://www.googleapis.com/auth/chromewebstore.readonly'];
var url = 'https://accounts.google.com/o/oauth2/v2/auth?'
+ 'client_id=xxxxxxxx.apps.googleusercontent.com'
+ '&response_type=token'
+ '&scope='
+encodeURIComponent(scopes.join(' '))
+ '&redirect_uri='
+encodeURIComponent(browser.identity.getRedirectURL());
browser.identity.launchWebAuthFlow(
{interactive: true, url: url})
.then(function(result){
console.log(result);
})
.catch(function(err){
console.log(err);
});
Using the browser.identity.launchWebAuthFlow() function I got a valid token from the returning result (in the query string on the access_token parameter).
Now I get call the Chrome WebStore APIs with no issue (I thought) with this simple code:
//access token
var token = 'previous_access_token';
//Google Chrome immutable Ext. ID from the store
var GOOGLE_CHROME_EXTENSION_ID = 'XXXXYYYYZZZ....';
//endpoint to get all purchased items (see https://developer.chrome.com/webstore/webstore_api/payments#resource)
var CWS_LICENSE_API_URL = 'https://www.googleapis.com/chromewebstore/v1.1/items/';
var req = new XMLHttpRequest();
req.open('GET', CWS_LICENSE_API_URL+ GOOGLE_CHROME_EXTENSION_ID + '/payments');
req.setRequestHeader('Authorization', 'Bearer ' + token);
req.onreadystatechange = function() {
if (req.readyState == 4) {
var license = JSON.parse(req.responseText);
console.log(license);
}
}
req.send();
Unfortunately this doesn't work at all, getting the following error:
(You don't have access to licensing data for App ID: xxxxyyyzzzzz)
I have the following evidences:
If I use a token got from the Chrome Extension using chrome.identity.getAuthToken() the call is ok
If I run the same script inside the Options page of the Chrome Extension, I get the same error
A specific Chrome WebStore API actually work (the get items API)
I guess for some reason Chrome WebStore APIs are not accessible using a token produced outside a specific context (i.e. Chrome extension subject of the call).
Does anyone have evidence of this? Google team are you there :) ?
I am trying to build a simple chrome extension that will block a list of websites. At the moment I have this:
function logURL(requestDetails) {
console.log("Loading: " + requestDetails.url);
alert(1);
}
chrome.webRequest.onBeforeRequest.addListener(
logURL,
{urls: ["*://*.google.com/*"]}
);
When I go to google I get an alert. When I close the alert I get another one and another one and they keep coming.
When I take out the
alert(1);
I don't get any alerts but I also do not get any console logs which I would expect.
Any ideas?
P.S I'm a junior developer and just learning so apologies if this is really simple, I would appreciate a detailed reply as it will help me develop my skills.
I'm developing a chatbot on azure using node.js. It's a data visualization bot which generates chart in html format using d3 library and display to user.
It seems that Microsoft bot builder doesn't support html format. But I have looked through this link:
https://blog.botframework.com/2017/09/07/html-not-supported-web-chat/
It says that there is a way to enable html content:
"If HTML rendering in Web Chat is a critical feature for your applications, you can clone or fork a copy of the Web Chat source code from GitHub, and enable it (on your own custom Web Chat client)."
I tried to clone the file and changed ‘html : false’ to ‘html : true’. But it's not working.
Can anyone tell me what I can do? Really appreciate it!!!
Depending on what data you are attempting to visualize, you might be able to use a service like Google Image Charts: https://developers.google.com/chart/image/docs/chart_playground
Using this service, with the following code:
// attach the card to the reply message
var msg = new builder.Message(session).addAttachment(createHeroCard(session));
session.send(msg);
function createHeroCard(session) {
return new builder.HeroCard(session)
.title('Months with Numbers Bar Chart')
.subtitle('Using a Chart as Image service...')
.text('Build and connect intelligent bots that have charts rendered as images.')
.images([
builder.CardImage.create(session, 'http://chart.googleapis.com/chart?cht=bvg&chs=250x150&chd=s:Monkeys&chxt=x,y&chxl=0:|Jan|Feb|Mar|Apr|May|Jun|Jul')
])
.buttons([
builder.CardAction.openUrl(session, 'https://learn.microsoft.com/bot-framework/', 'Get Started')
]);
}
Produces this hero card:
I am building a bot service to communicate to various endpoints. I have Skype basic communication running through Microsoft Botbuilder in Nodejs. I can send text to the Skype client fine, however when I want to send rich messages with images (animated gifs) or videos, things start going haywire.
1) Sending a animated gif:
function createAnimationCard(session) {
return new builder.AnimationCard(session)
.title('Microsoft Bot Framework')
.subtitle('Animation Card')
.image(builder.CardImage.create(session, 'https://docs.botframework.com/en-us/images/faq-overview/botframework_overview_july.png'))
.media([
{ url: 'http://i.giphy.com/Ki55RUbOV5njy.gif' }
]);
}
I call this code from another function:
exports.sendGif = function sendGif(chatBotUserSession, picUrl, contentType) {
var card = createAnimationCard(chatBotUserSession);
var reply = new builder.Message(chatBotUserSession).addAttachment(card);
_bot.send(reply);
};
When I do this I get to see an image with a play button (in the desktop Skype, mobile client does not show image at all), however pressing the button shows an error "opening not possible". I have tried different gif sources in the url field, but none seem to work. Also tried https for source.
2) I then moved to trying to display a video:
function createVideoCard(session) {
return new builder.VideoCard(session)
.title('Big Buck Bunny')
.subtitle('by the Blender Institute')
.text('Big Buck Bunny (code-named Peach) is a short computer-animated comedy film by the Blender Institute, part of the Blender Foundation. Like the foundation\'s previous film Elephants Dream, the film was made using Blender, a free software application for animation made by the same foundation. It was released as an open-source film under Creative Commons License Attribution 3.0.')
.image(builder.CardImage.create(session, 'https://upload.wikimedia.org/wikipedia/commons/thumb/c/c5/Big_buck_bunny_poster_big.jpg/220px-Big_buck_bunny_poster_big.jpg'))
.media([
{ url: 'http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4' }
])
.buttons([
builder.CardAction.openUrl(session, 'https://peach.blender.org/', 'Learn More')
]);
}
When I call this using:
exports.sendMovie = function sendMovie(chatBotUserSession, picUrl, contentType) {
var card = createVideoCard(chatBotUserSession);
var reply = new builder.Message(chatBotUserSession).addAttachment(card);
_bot.send(reply);
};
It all works... at least on my desktop Skype. My mobile skype (iOS) now crashes each time when I open the chat with my bot...
So two questions:
1) Does anyone know why I can't seem to send animated gifs that actually play?
2) Anyone have experience with bots on mobile Skype sending rich content and consequently crashing the app?
Thanks.
How I can send a notification for everyone that has installed my extension?
I'm using new Notification(...) but the notification is just sending for me.
Thank you for all
You will want to use the new gcm service for Push Notifications via Google Cloud Messaging Service.
Here is a tutorial on Google's Chrome Developer page.
Well, this requires a lot of work already done in the extension to be able to do that without updating the extension.
For instance, your extension can periodically look for new notices on your website.
If you need more urgency, you either need to keep WebSocket connections to your server or use some manner of push services, like gcm API that Max Worg just mentioned.
That said, to use all this you need to have the support already in place in your extension.
Okay, but suppose you don't have that support, or don't need it that often.
The usual way to do it is with an extension update, where you add a message for the users and increment a variable with the "release notes" version, so that it will only be shown once. A good idea is to use chrome.storage.sync for this, so that the user won't be annoyed multiple times.
var message = "Sup user, check this out!";
var message_version = 4; // Update this when you want to show a new one
chrome.storage.sync.get(
{message_version: 0}, // Provide default
function(data) {
if(data.message_version < message_version) {
notify(message); // TODO: implement notify()
// Alternatively, open a page with the notice with chrome.tabs.create()
chrome.storage.sync.set({message_version: message_version});
}
}
);
You can see a real-life example here (using a hybrid of localStorage and chrome.storage).