Comments (22)
AFAIK it's supported on v1_train builds of B2G/FirefoxOS, and only there. You also have to define a preference (on custom-prefs.js in gaia, for example) for it to work. The preference is
pref("services.push.serverURL", "wss://put.your.server.addr.here");
At this time we don't have a publicly available test server, but we hope to have one soon. We'll update this once it's available.
from pushjslibrary.
About the simulator, maybe @nikhilm or @mykmelez could know
from pushjslibrary.
I see in FF 23 in about:config a setting services.push.enabled which is set to false, but setting it to true did not help with the navigator.push or other variables which @mvayngrib listed. Also, note that all those variables are undefined except navigator.push, which is null. Not sure if it has any significance.
from pushjslibrary.
This should be available in all B2G builds since the patches are on m-c and b2g18.
Set services.push.enabled to true and services.push.serverURL to "wss://nikhilism.com:9082" and things should work. Note: The server is a dev server and there are no guarantees about uptime and delivery.
from pushjslibrary.
@nikhilm thx for the info and the permission to use your server. If some node.js server exists which we can run ourselves, we will do it. Will this one work:
https://github.com/telefonicaid/notification_server/wiki/SimplePushv1---Developers
Also, is it possible to set those prefs in Firefox OS Simulator? I can't seem to find where.
I tried the method for changing prefs provided by the Telefonica server in the above github link, but it does not work for me, the command:
adb pull /data/b2g/mozilla/<your_id>.default/prefs.js
gives me:
error: device not found
from pushjslibrary.
@urbien you can try to use our server: https://github.com/telefonicaid/notification_server, it requires mongodb (persistence) and rabbitmq (messaging). You should use the v1-fix
branch.
Default configuration should work out of the box.
We are planning to open our server for devs experiments later this week.
from pushjslibrary.
@urbien The nikhilm/go-push-server might be easier to deploy for testing, it has no dependencies other than Go.
By FxOS simulator do you mean the one that runs in Firefox, or do you mean the standalone FirefoxOS emulator that behaves like a mobile device?
Are you building b2g/gaia from source? For source builds its easy. You can either modify /b2g/app/b2g.js which has the push entries. Or you can edit /build/
If you are using a nightly I'm sure there are similar files to edit.
from pushjslibrary.
@nikhilm so far I was using Firefox OS Simulator as a browser add-on on Ubuntu 13.04, and Win 7 and a b2g standalone, on Win XP. If not possible to change prefs in add-on, I will try to install b2b on Ubuntu 13.04 and Win 7. Thx for heads up on a push-server, I do not need persistence and guaranteed delivery at this point, so will try to use it.
@willyaranda thx, will give telefonica notification server a try a bit later, as I never had Mongo and rabbitmq experience, so will need to learn.
from pushjslibrary.
I see that in b2g v25 the push server url is not empty anymore
pref("services.push.serverURL", "wss://push.services.mozilla.com/");
(this line is from ./defaults/pref/b2g.js)
Great, but what is the URL of the server that our app server can send notifications to?
Using the above URL with http and https schemes in browser gives: not websocket protocol
from pushjslibrary.
To get the URL that you'll use to send notifications to, you need to call navigator.push.register(). That returns a DOMRequest and the onsuccess handler will be called with the endpoint as a parameter.
from pushjslibrary.
@AntonioMA I'm testing push notifications in the FirefoxOS Simulator add-on and the DOMRequest returned by navigator.push.register() never hits onsuccess or onerror. Here's my (very) simple test: https://github.com/mvayngrib/SimplePushTest.
You mentioned earlier: "AFAIK it's supported on v1_train builds of B2G/FirefoxOS, and only there." I'm not really sure how to get the v1_train build or determine whether or not it's used in the simulator add-on.
from pushjslibrary.
The Firefox OS Simulator does include a version of Gaia from its v1-train branch. The latest preview build (Windows, Mac, Linux) uses the tip of the v1-train branch as of 2013-06-26.
from pushjslibrary.
@mykmelez I tried using the latest preview build from your link with FF 23 as well as Nightly (25.0a1) and navigator.push.register() still doesn't call back.
from pushjslibrary.
I grepped through Simulator files, and it looks like push is enabled in the B2G Desktop executable bundled with the addon:
defaults/pref/b2g.js:pref("services.push.enabled", true);
defaults/pref/b2g.js:pref("services.push.serverURL", "wss://push.services.mozilla.com/");
defaults/pref/b2g.js:pref("services.push.userAgentID", "");
defaults/pref/b2g.js:pref("services.push.retryBaseInterval", 5000);
defaults/pref/b2g.js:pref("services.push.pingInterval", 1800000); // 30 minutes
defaults/pref/b2g.js:pref("services.push.requestTimeout", 10000);
defaults/pref/b2g.js:pref("services.push.udp.wakeupEnabled", true);
defaults/pref/b2g.js:pref("services.push.udp.port", 2442);
greprefs.js:pref("services.push.enabled", false);
( greprefs.js disables it, but b2g.js enables it, and I think the latter takes precedence.)
In your SimplePushTest app, I notice that your push permission doesn't have a description property. I'm not sure if that matters, but according to App Manifest - Permissions it must have one, so you might try setting that and reinstalling.
from pushjslibrary.
Is navigator.push non-null? If it is non-null, then permissions are not the problem. You might want to check if there is any network activity. The onerror should fire after about 10seconds with timeout if there is no reply from the push server.
from pushjslibrary.
I tried using the Simulator nightlies and push is not available. On digging around it seems that although Gaia v1-train is used, the b2g version used is v1_0_0 whereas push is in 1.1. @mykmelez is there a build of Fx simulator available that uses b2g (Gecko) 1.1?
from pushjslibrary.
@mykmelez re: description - didn't help unfortunately.
@nikhilm re: onerror timeout - timeout never fires. I ran netstat -abf as administrator and I don't see any network activity when running SimplePushTest
from pushjslibrary.
@mvayngrib see my comment just above yours :) So push is not available in the current simulator.
If you need to test it immediately, please try a nightly builds based on mozilla-central of the b2g desktop.
See
https://developer.mozilla.org/en-US/docs/Mozilla/Firefox_OS/Using_the_B2G_desktop_client
and
http://ftp.mozilla.org/pub/mozilla.org/b2g/nightly/latest-mozilla-central/
Sorry about that.
from pushjslibrary.
Hm, no luck so far with the B2G desktop client. I tried the following builds:
-http://ftp.mozilla.org/pub/mozilla.org/b2g/nightly/latest-mozilla-central/b2g-25.0a1.multi.win32.zip
-b2g 24.0a1 - can't find the link anymore
-https://ftp.mozilla.org/pub/mozilla.org/labs/r2d2b2g/b2g-18.0.2013-06-26.en-US.win32.zip
On Windows 7 it hangs on the "based on mozilla technology" startup splash screen, and on Windows XP is promptly crashes.
I also tried the b2g-desktop-client from:
https://github.com/sihorton/b2g-desktop-profile-installer/
(installer at https://github.com/downloads/sihorton/b2g-desktop-profile-installer/b2g-gaia-desktop.exe)
...updating it to the aforementioned versions--25, 24, 18--using their directive "extract the download into the b2g-gaia-desktop directory over the existing code," after which b2g-desktop-client fell ill. First it threw up a popup asking to upgrade to 0.6, and then after the upgrade it refused to start, crashing immediately.
I'll try it in Ubuntu, maybe I'll have better luck. Has anyone gotten it working there?
Also, how does one install apps in B2G desktop? In the FirefoxOS Simulator add-on it's very straightforward, but I'm having trouble finding the directions for B2G desktop.
Thanks for your patience guys!
from pushjslibrary.
@mvayngrib Sorry you're having problems. I've been using development versions far too long to think about this. Today I will try building one of the nightly builds for the simulator or the desktop and see what I can figure out.
from pushjslibrary.
@mvayngrib So I tried the Linux version of latest-mozilla-central/b2g-25.0a1...
Extract it and run the b2g executable and it should work. One way to install apps is to host it somewhere, and have the app kickstart itself using mozApps.install() when its visited in the browser.
Another way is to clone gaia, drop your app into the gaia external apps directory, make the profile, and tell b2g to use this profile.
I'll see if I can get the simulator itself using the b2g nightly. I'm having some problems starting it.
from pushjslibrary.
Since PUSH is now in FF and Chrome using Service Workers [1], I can close this issue.
[1] https://developer.mozilla.org/es/docs/Web/API/Push_API
from pushjslibrary.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pushjslibrary.