inovramadani
inovramadani

Reputation: 2047

Are websocket, playing audio in background, and storing files locally possible in KaiOS app?

I am planning to develop a chat and voice messaging app in KaiOS, but want to make sure whether these things are possible in KaiOS:

Upvotes: 0

Views: 219

Answers (2)

Tom
Tom

Reputation: 7091

  • Background WebSockets aren't supposed by any browser, or on KaiOS. You can use Web Push to receive push notifications in the background.
  • Background audio playback is supported
  • Files can be read and saved locally using the Device Storage API

Upvotes: 0

Kiran Jadhav
Kiran Jadhav

Reputation: 66

Web Sockets : Web sockets can work only if the app is at foreground. You can use window.MozWebSocket or websock.js.

If you want to do any data exchange activity in background, then make use of push notification, serviceworker and indexed db/cache API.

Storing files : Yes you can read and write files

To read,

var sdcard = navigator.getDeviceStorage('sdcard');
var request = sdcard.get("fileName");
request.onsuccess = function () {
        var fileObject = this.result;
};
request.onerror = function () {
   console.warn("Unable to get the file: " + this.error);
};

To write,

    var sdcard = navigator.getDeviceStorage("sdcard");

    var request = sdcard.addNamed("file data", "test.txt");

    request.onsuccess = function () {
      var name = this.result;
      console.log('File "' + name + '" successfully wrote !!');

    };
   request.onerror = function () {
     console.warn('Unable to write the file: ' + this.error);
   }

Upvotes: 1

Related Questions