How to grab selected HTML from browser and pull into my app - cocoa

I'd like to create a Cocoa app that is able to grab selected text from a website in a third-party browser (in other words, NOT from an embedded webkit instance running within my own app) and then store it in my app's database. From what I can tell, I need to user some kind of service for this, like how selected text in Textedit can be turned into a new sticky note via a service. However, I'd like to be able to provide this app through the App Store. Does that mean I need to use XPC services?
That's as far as I have gotten. So if I do need to use XPC services, can someone point me in a helpful direction? The Services Implementation Guide is totally over my head.

Related

With a Spring MVC webapp, can you take a photo on a mobile device and upload it to the server?

I was asked to write a webapp using Spring MVC that among other things it must either take a photo on a mobile device or at least upload it from the device's photo library. Apparently we have some product (probably .NET based) that allows taking/uploading photos from the a web page displayed on a mobile and is where they got the idea from. Most devices will be iPhones but some might be Android.
Is this even possible with a Spring MVC webapp - with no code on the mobile device?
If yes, how would you go about designing this? Is it simply a matter of implementing a file upload as you would from a PC and trust that the mobile device will somehow magically handle the "take a photo" or "pick the photo from the image library", or is there more to it?
Is there anything else I need to know about?
Yes, although I am experienced with Spring MVC and even "normal" webapps that are accessed from a mobile... I am clearly clueless about this type of "photo" app.
write the web app allow access to the camera through the browser of device, when the users take the photo send it to web app or simply create the form allow user select image from device. ( with browser of device you can access camera or folder on device

How can I build a webapp which uses google calendar api without having to become verified?

What I want to build:
I want to build a website where users can connect their google calendars (this will use Google Calendar API's)
and view their calendar events, as well as edit them, and create new ones.
My problem:
In order to do so, google says my app needs to be verified, which can take weeks, and I also need to set up terms of services pages, privacy policy pages
I also need to supply authorised javascript origins which MUST start with https, which of course is a problem during development, since my origin is http://localhost
I also need to set up support emails and homepage link
Question
I just want to start building my application without having to set up a whole production-ready website eco system.
Is there anyway I can use these Google Calendar APIs for editing/creating calendar events locally, without having to set up everything mentioned above first?
Unverified apps can still be used by the developer who created the project on google developer console.
Unverified app screen
The app or script might display an "unverified app" screen before it displays the consent screen. This is based on the specific scopes that your app includes in the request.
You can still work on your app while you are going though the verification process. However that being said i would start that process asap it can take a long time to get verified.
Yes, you can. As far as I am able to tell, all the verification step does is remove the "unverified app" screen. As long as you click Advanced > Go To ... (unsafe), you should be able to create and edit calendar events for that user in your application.
In order to be able to create and edit calendar events, you need to use the most sensitive scope, which is https://www.googleapis.com/auth/calendar. I couldn't figure out how to edit and create calendar events in my web app until I changed my scope from calendar.events to calendar.
Creating Events: https://developers.google.com/calendar/create-events

Create Docs through the Drive API with specific page setups (margins, orientation)

My app is already able to create Google Docs through the Drive API, and when doing so I can choose the title, data, and metadata. But I've been looking at the documentation and it seems there is no way to set some other properties of the Docs, such as the margins and the orientation (portrait or landscape) of the Docs being created. Is there a way to do so?
After not finding an answer in the documentation, the only thing I could think of was logging in with my Google Account, going to one of the created Docs, click on "Page setup", then select "Landscape", and finally "Set as default". I thought that by setting it as the default in my Google Account, it may happen that all the Docs created with it may be created as Landscapes. But it didn't work. A possible reason, however, is that the account actually creating the documents is a Service Account, not my regular Google Account. I guess both accounts, while being linked, are not the same thing, so the defaults of one don't apply to the other. Is there some way to set "Portrait" as the default orientation for the Docs created with my Service Account? If not, would the solution be to stop creating the Docs with my Service Account, and start creating them with my regular Google Account, so that the defaults I apply to them apply too to the newly created Docs?
Drive API doesn't support Docs related features for you to retrieve/set metadata about the documents.
Service accounts are individual Google accounts and no way related with your own user account. On the other hand, your default settings will only apply to you. You cant programatically set other user's defaults.
The best way I can think of, which is really a hack, is to make your own google docs API using headless chrome and pupeteer, which could be used only in part, and in connection with, the official docs API.
This is basically a web browser that runs on your server, which can be controlled to do anything a client would normally do on a web browser, like click buttons, submit forms, etc, only at the command of a server, which can be commanded through HTTP requests etc.
So after installing puppeteer, open the chromium browser, log into your google account, then open google drive with the server, and you should already be logged into the account. If not, you may have to log into the account using the server logic, which can get complicated with 2 step verification...
but anyway once you are logged into your google account on puppeteer, on drive.google.com, simply stay on that page and wait.
If the server receives some kind of HTTP request to make a new document, then have the server just literally click the new document button on the webpage, and it should open the new document in a new tab, which you should be able to access with puppeteer.
Then, when it is made, you can either just send the URL back to the request server, and / or make your page setup changes now, based on the data received in the HTTP request earlier.
For example, if, at one point (either after the document is created, or during its creation), there is some kind of message specifying the color of the background, just manually, on the server side, click File -> page setup, and select Custom, and, programmatically "type" the hex color code etc then click the OK button, then end the POST request.
If you have any questions, let me know
var doc = DocumentApp.getActiveDocument();
var body = doc.getBody();
//turn landscape if portrait
var oldHeight = body.getPageHeight();
if (oldHeight > body.getPageWidth()){
body.setPageHeight(body.getPageWidth());
body.setPageWidth(oldHeight);
}

Access to SMS and browser content tombstoning

WP7 newbie here..
In my application, I am using embedded web browser control to load an external web page.
I have a PIN based validation step in that application, which involves
1) User Leaving the current application, (which has a external web page loaded in the embedded web browser) to launch the SMS Inbox.
2) User reads the SMS he just received, which has the PIN. I am sending this SMS to the user.
3) The User then needs to resume back to the original application by hitting back button, to enter the PIN which he received in the SMS earlier.
Once user enters Step2, my application will go into background, and subsequently will get tombstoned. Once user enter Step3, I want to restore application state (with the embedded web browser control), without making a fresh HTTP request again to load the web page.
So, with the given scenario in my mind, I have following two questions -
1) Is there a better way to do all this, like not having to exit the original application, and still let user read the SMS. ( i.e any api to read sms ?)
2) Is there a way to serialize the browser state/save entire web page (with images, css, js) , such that entire web page can be rendered exactly the way it was, when user left the running application.
Important points:
1) I can only use SMS as a communication channel. I can not use something like raw push notification channel, which could let me show PIN to the user, without exiting the application.
2) I am targeting Windows phone 7.0 runtime, but if there is a better option available in Windows Mango update, please do tell me.
Any sort of help is greatly appreciated.
Update:
Added link to the embedded web browser component.
1) There is no API that would let you access the contents of the Messaging hub from inside your application. This is set up for privacy purposes.
2) By default, the web browser saves its state. So if you navigate away from your app, and then come back - the same web page will still be there unless you explicitly re-navigate on activation
1) The better way to do this would be to not embed the web page within an app. Just build a mobile website. If all the functionality is within the web page you gain nothing but problems by trying to put it inside an app.
The web browser control is not intended to be used to create an alternative browser (which is really what you're doing).
2) You can try using the SaveToString() method to store the state of the page when tombstoned but this doesn't allow for modifications to the page since it was loaded (including anything dynamically updated or any state in javascript). If you have multiple pages you'll also need to maintain the internal backstack and the state of each page separately.
Short answer: If you want to put your application logic in a webBrowser control then you can't support tombstoning. Fast-App-Switching (in Mango) partially addresses this but not completely.

Is it easier to register a custom protocol or a MIME-association across OSes?

From a web browser (Win/Mac) I need to launch a desktop application and pass it a response string (e.g. XML) from the webserver. For Windows, as far as I can tell I have two straightforward options:
Set the application as a default program, and respond in a standard way so the browser associates the response with that extension/Content-type. The browser validates the association, stores the response to a temp file and the app opens it.
Register a protocol, which causes the browser to launch the app, passing the URL to it. In this case apparently the string needs to be something like Base64-encoded (yet shorter than the browser's URL length limit). Otherwise I'd store the file on the webserver and the URL would be given to the app to request itself. This seems to be less than ideal, but iTunes uses it (itms://).
Which is generally easier to register by app installers across platforms? What I don't know at the moment is the particular installer framework being used by this app.
I have NO development experience with this but I think it's all about what you are developing and the business model.
Option 1
Would be useful when you create some sort of custom meta data file which can be viewed nicely in an application.
Company X has their own XML Schema's. Customers can download their data in that format.
Company servers serve these files with their registered/custom content-type. Customer can install an application that handles that content-type. Application development is focused on supporting the XML Schema's and build an interface upon it.
Option 2
Would be useful when you distribute content online.
Apple turned their iTunes business model into a protocol. So every channel (web,browser extensions,mobile apps,desktop,mobile sites,company devices,etc) they want market share can use that protocol. Application development is focused on supporting the protocol (business model) and build an interface upon it most fit for the channel.

Resources