How to use Chrome Push Notifications from Http site - javascript

How can I integrate chrome push notification (GCM) on my HTTP site. That would be great help if i could get any sample related to this? According to Google documents this is only for HTTPS sites, but is there any way to integrate push on HTTP site?.
Please help me, I am stuck here?

The Web API needs a service worker so the piece that receives the events needs to be https for sure.
I am not sure if you would be able to register via http through some iframe trickery but I would not count on it. Even if you manage to do it there are no guarantees that it will keep working since as you say the documentation says it is only for https sites.

It is possible only with https site. But the workaround is this you will have to maintain one https domain. For Http site, you will use an iframe or Modal for getting a subscription and redirect to your https service worker. This is the only way to do this.

Related

How to capture (initialisation) errors from a cross-domain iframe?

I'm setting up a micro-frontend solution which contains the main integration app which resides in the main window and a bunch of iframes with services (sub apps). This services are SPA's but not necessary and are served from another domains but I can control them. The main app needs to get some configuration from underlying services and it works the following way - the couple of embedded urls integrated into index.html and the main app knows what to load then it needs to wait for events through postMessage API, one per each iframe.
The problem here is that the main app doesn't know if something goes wrong inside an iframe during initialisation stage: the service is down due to different reasons and the app isn't loaded inside an iframe, or the app inside an iframe lost a connection to the server or JS syntax error. The only way to detect that is just using a timeout, but that's not the best UX. A user will wait for example for 30 seconds before seeing an error.
Are there any possible ways to gain an access to iframes from the main window? May be by using CORS? It's clear for XHR requests but I haven't found info regarding iframes and CORS.
Are there any possible ways to gain an access to iframes from the main window?
Only postMessage, which you are already using.
May be by using CORS? It's clear for XHR requests but I haven't found info regarding iframes and CORS.
You cannot use CORS to grant cross origin access via frames.

Allowed referrers in google maps API (cordova)

I created an API key for gmapsv3 but it's asking me for allowing some HTTP referrers.
What is the referrer for a cordova app, since there is no URL?
I left * for the moment but how to secure my key?
I'm under meteor and tries meteor.local, but it doesn't seem to work.
Thanks
You could potentially change the native code to add a referer, and lock your maps key down to that... there is an example of such here.
Alternatively if you want a platform independent solution you could add implement a proxy on your server, keep your Google Maps key there on the server and have it make requests to Google Maps on your behalf. This would introduce another layer of network calls, then you'd also want to secure your proxy so that you can be pretty sure that the requests are coming from your app - maybe by setting a custom HTTP header that your server can look for.

How do I load a Web Worker script over HTTPS?

I am attempting to use a Web Worker to offload some CPU intensive calculations into a separate thread. For a little context, I am taking an audio stream from getUserMedia and saving it into a file to be uploaded to my service after it is complete. I am able to retrieve the stream from the user and play it back via the WebAudio API and through an HTML5 player, but now I need to take the next step of saving it into a file.
The problem:
My main service is running over an HTTPS connection, since it is restricted to signed in users only. I have a worker script that does what I need it to, and I am attempting to load the script in via a relative path into my worker. I am receiving the following error
Mixed Content: The page at 'https://someurl.com:1081/some/path' was loaded over HTTPS,
but requested an insecure Worker script
'http://someurl.com/some/path/lib/assets/javascripts/worker.js'.
This request has been blocked; the content must be served over HTTPS.
I figured it was because I was using a relative path in my code like so:
worker = new Worker('lib/assets/javascripts/worker.js');
I wanted to rule this out so I made the following change:
worker = new Worker('https://someurl.com:1081/some/path/lib/assets/javascripts/worker.js');
This did not solve my error. It appears that the Worker is loading my script via HTTP no matter what url location I attempt to use. I couldn't find any reference on how to use the Web Worker via HTTPS, so I am hoping someone can provide some insight.
Possible Solution
I do want you to know there is a possible solution, but it seems a bit hacky to me. I can load my worker script up as a Blob and pass that directly into the Worker. If this is the only solution, I can make it work. But I was hoping to find a way to make the script load via HTTPS.
Have you tried
//someurl.com:1081/some/path/lib/assets/javascripts/worker.js
instead of
https://someurl.com:1081/some/path/lib/assets/javascripts/worker.js
Just something I found here,
Deezer content is served over HTTP
I solved this. The error itself was misleading and caused me to go down a rabbit hole looking for the solution.
The issue here actually stems from the way I have this service configured. The service that starts the web worker is actually proxied behind another service, and all requests go through the parent service. This works great for most requests, but was causing an error in this case. Instead of forwarding the request on this port to my app, the web worker was attempting to download the worker script from the parent service itself. This means the error stemmed from the fact that the script wasn't found, not that the protocol was incorrect.
To solve this, I had to pass in a localized script location from Rails using its asset pipeline. This allowed the worker to grab the script and actually work.

Listening to http GET requests in chrome

I am about to look at building an extension for chrome that can listen to a particular http GET request, and then react by passing the body on to another application.
This will be limited to one website, and I am only concerned about the one request (though the query parameters can change)
The data will most likely be communicated to the other application using another GET or POST request by the extension.
I am new to most of the topics concerned with this issue. I have not used created a chrome extension before, though I see it has a lot of documentation which has helped greatly.
The question I am asking is how in a google chrome extension do I react to a GET request?
I am aware there is a network view in the dev tools, so I guess what I am asking is probably possible. I had guessed it may be done with an "Event" as listed here http://developer.chrome.com/extensions/events.html , but I cannot find the "onGET" event or similar
Thanks,
Luke
It would appear that this is not particularly easy to do. There is an "onCompleted" callback with the chrome "webRequest" API, but that would not allow me access to the body.
What I have had to do to solve my issue, is get the plugin
https://chrome.google.com/webstore/detail/proxy-switchy/caehdcpeofiiigpdhbabniblemipncjj/related
And set up a proxy on my local machine. ProxySwitchy detects the request to the URL I care about, and uses my proxy instead. My proxy then duplicates the message and allows me to do with it as I please.

Not able to display my connections using Connections javascript API

I am developing a chat application which requires linkedin authentication for its users. I had a look at the sample code on the Connections javascript API page and wanted to test it out. While the direct link http://developer.linkedinlabs.com/tutorials/jsapi_connections/example.html retrieved my connections to perfection, running the code on my localhost yielded no results(no errors though). It simply does not seem to fetch the connections. I tried obtaining the connections in tag:JSON format first, but even this was an exercise in futility. Note however that the Profile API works on both the localhost as well as the example on your page. Please help!!
Regards,
It sounds like you haven't set the JavaScript Domain properly - you need to set the JavaScript API Domain field of the Application Settings to http://localhost for the application to function when running locally.

Categories

Resources