Rails send data to a serial on client - ruby-on-rails

I need to print from my rails app to a printer on the client side of my app
How can I acess the printer from browser to print on client side with rails?

Browsers won’t let you do this without user interaction (the user will need to select print from the file menu while looking at your app’s page).
If you’re ok with that; then this isn’t so much a rails problem as creating a view which will print nicely. For that you’ll want to look at css for print media types.
But before we get any deeper - do you require that your web app have direct access to the printer without user interaction?

Related

Messenger bot, safety of parsing user ID to a webview URL as a parameter

I'm currently building a food ordering Messenger bot that uses an extension for the menu, as it is a much faster way to browse and select in the restaurant menu rather than using carousel or lists and repeated questions about the quantity.
However, using extensions currently limits the use to mobile users. An extension is used(rather than a plain web-view) to get the user messenger id to determine which user is making the order. An idea came across my mind to switch to a regular web-view to allow desktop users to use the bot, as currently the messenger opens the web-views in a frame rather than in a new tab, but this means that the only way to determine which user is ordering is to pass the user ID (bot`s database user table ID, not the messenger ID) as a URL parameter for the menu.
My question is, how safe and is it even a good idea to do so?
This would depend on how sensitive the user ID is. If the API that accesses your database is properly secured, then it should not be a problem, since no personally identifiable information can be extracted with just the user ID.
If you wanted to be really safe and not expose the user ID from the database at all, you could store the PSID from Messenger in the user db record, then send and do a look up on that instead.
So, I guess the short answer is, it's as secure or insecure as anything you would pass around over HTTP, since the webview in Messenger is a plain webview.
First, although this may have been different when you posted your question, Messenger Extensions now absolutely do work on the desktop versions of Messenger (both when using messenger.com directly from the desktop, as well as when using the version of Messenger embedded within facebook.com). That said, I would recommend using the Content-Security-Policy directive to allow both messenger.com and facebook.com to display your webview as a frame within the browser, rather than the X-Frame-Options recommended by Facebook at https://developers.facebook.com/docs/messenger-platform/webview/extensions#webview_on_web . X-Frame-Options forces you to choose a single domain (messenger.com or facebook.com) to allow your webview to appear on, whereas with Content-Security-Policy you can allow both.
Second, it's worth pointing out that even if using Messenger Extensions, if you're not validating the incoming data using signed_request, then anyone can spoof an order acting as that user. The instructions at https://developers.facebook.com/docs/messenger-platform/webview/context#signed describe how to validate incoming info from getContext() to ensure that the information really did come from Messenger.

Need to open web page within telegram bot chat -- big picture

Building my first telegram bot and it's going to be quite complex.
Part of workflow needs to open a webview within telegram that will require user interaction, return to bot chat altering chat with data received from user.
Reading through the entire api, SO, github, I'm having trouble finding anything about the viewing webpages, much less if we can interact. Before I get deep into this project it would be awesome to have some starting direction.
Can you create web views (like you see for "instant view" articles, google maps, etc), and if so can you get data from user to use back at the chat bot?
Another option is possibly using a "game". In our case, it won't be a conventional game, but maybe we could use the html5 game to render what we need, and interact with the user. I know it can pull scores, names, etc to update message, maybe we could somehow make this work?
I'm currently working through the api. This is one of my first apps, and my first telegram bot. I really appreciate any assistance on how to get started here.
This is in Rails, using https://github.com/telegram-bot-rb/telegram_bot_app as a starter. Mostly needing to know if this concept it possible, but anything more specific would be great, too. Thanks!
You can't create web view with the bot API and you don't need to do that. You can simply link to a web page using simple links or inline buttons and the page will open in Telegram's inline browser (Depending on user's settings).
If you include the user ID in the URL you will know who is using the webpage. e.g example.com?uid=1234
Now that you know who is using the webpage, you can use the ID to send messages or anything else in Telegram chat while user is on the webpage.
At the end you can redirect the user back to your bot URL (telegram.me/botusername).
Update
You can now use Seamless Telegram Login to link to a web page and log in the user. This feature can also be used in groups
Try the new Telegram Web App API
It can open a web page on the bottom sheet, which you can expand almost to the full screen.
You can configure the web app open button by following these steps:
Open BotFather
Type /mybots, select your bot
Click Bot Settings > Menu Button
Set up a menu button that opens a certain URL

SKProductsRequest over server?

I have an app where I get a list of product IDs from the server, which I then send to Apple to get a list of SKProducts, which I then send back to the server to get html, which I put all together to make a webview with the products.
This is very complicated- is there a way for the server to communicate with Apple directly without having to do all the back and forth?
No. Your app has to make a request to the iTunes store directly from the device it is running on (to ensure correct handling of the user's iTunes account, including appropriate prices for the region, etc.).
It sounds like your app-server communication structure is not the most efficient; it'd be easier if you generated the storefront web view inside your app, locally on the device (or even found a better, native way of displaying the information, such as a UITableView or UICollectionView), instead of sending the IDs to the server. This would eliminate a lot of the back-and-forth resulting from you doing this in a way that was certainly not intended.

Capture print requests from a UIWebView

I have an app that is a wrapper for a website. It allows us to use a third party web app for some services in our business. One of the things it will do is print labels. In mobile safari if I do the setup and press print, the request is processed in safari and I can print without any issue using air print.
Inside of my custom app the uiwebview makes the same request however nothing is sent to the printer. I have added a popover that I can manually submit a print job, but I can't manage to capture any print requests that come from the webview.
I was able to get in touch with an Apple engineer who confirmed it is impossible to receive the window.print request from UIWebView. For my purposes, I just use javascript to change the window.print function to a command that will tell me the print request was made, and then I can print the part of the webview that I needed.

On blackberry : making a phonecall within an app on user action without J2ME?

Is there a way of making a phonecall within an application using Browser application development ? (for example using a link with a protocol similar to 'mailto:user#example.com' but that would make phonecalls instead of sending mails.)
If not, is it possible to make phonecalls using the Rapid application development ?
If this an app hosted in a browser, Blackberry respects WAP conventions for encoding a phone number.
Here's an example snipppit for displaying a number that is callable via a Blackberry device:
<a href='wtai://wp/mc;5551231367' title='Call'>555.123.1367</a>
I've been using this approch for some time now and it works for me. When the user clicks the link, a dialog from the OS pops up and asks if you would like to call this number.
Additional Information
I also recommend checking out Blackberry's additional resources on development. Since the current browser is still in the stone age compared to iPhone/Android it's worth seeing what's possible.
http://na.blackberry.com/eng/support/docs/subcategories/?userType=21&category=BlackBerry+Browser

Resources