Hello!

I'm trying to implement pushwoosh on Electron ( https://electronjs.org/ ).

Electron uses Chromium (google chrome core) to create native apps.

Although, the chrome API is not working, since electron is missing some implementations of push notification.

In other words, I cant use service workers becasue Electron loads urls from file://, and even if I used https, serviceWorkerRegistration.pushManager.subscribe() is not implemented. Remember that electron uses chromium, not chrome.

Of course, if I open my app in google chrome, pushwoosh works.

So I decided to implement the pushwoosh manually, sending https requests to /registerDevice endpoint. (https://docs.pushwoosh.com/reference)

Also I used this plugin https://github.com/MatthieuLemoine/electron-push-receiver that receives the notifications directly from google firebase.

And it worked! Everything worked wonderfully. I can use pushwoosh now on electron.

But althought it worked with a simple register device endpoint, I know pushwoosh does much more than that.

For example the hwid. I could not find where or how to generate it properly. I'm generating my own hwid with a random string and it seems to be working. But I wanted to be able to generate the same hardware Id that the chrome api uses.

Remember I can't load the chrome pushwoosh api, it crashes on electron for lack of methods implementation and no service worker.

So my questions are:

1 - Is there a way to generate hardware id ? I saw the chrome pushwoosh JS minified code and it generates from the push token and pushwoosh application id. But reading the minified code is very hard and gave me headaches. Is there a non-minified method stub I can call to generate this value? Is it ok If I simply generate my own? (it seems to be working for now).

2 - is there a guide on when and which methods to call manually on the endpoints (https://docs.pushwoosh.com/reference) to implement pushwoosh manually?

3 - will I be missing any pushwoosh features if I don't implement all the optional information on every pushwoosh endpoint? (I think the methods are register device and application open

Thanks.

Danilo

asked 15 Feb, 00:21
mirrorlink's gravatar image

mirrorlink
112

Ok I finally was able to read the code.

So the hwid on chrome is actually:

this, to generate a 'fake token':

for (var fake_token = "", r = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", n = 0; n < 32; n++)
{
  fake_token += r.charAt(Math.floor(Math.random() * r.length));
}

and then this, to make the generated 'fake token' hexadecimal i guess

   for (var t = "0123456789abcdef", hwid = "", n = 0; n < 32; n++) {
        var i = fake_token .length - n - 1, s = 0;
        0 > i || (s = fake_token .charCodeAt(i)),
        hwid += t.substr(s % t.length, 1)
    }

console.log(hwid);

so, hwid is a 32 position random A-z and number string converted to hexadecimal. And saved in the localStorage for all eternity... well or until cookies are cleared.

in other words.. its just a random generated string. Answer 1 is cleared!

permanent link
answered 15 Feb, 02:48
mirrorlink's gravatar image

mirrorlink
112

edited 20 Feb, 11:51

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×326
×76
×15

question asked: 15 Feb, 00:21

question was seen: 35 times

last updated: 20 Feb, 11:51