Code Monkey home page Code Monkey logo

Comments (6)

nikhilm avatar nikhilm commented on August 13, 2024

2 seperate permissions. The dialog is a UA issue and not spec detail.

Ideally the UA would be able to combine them since the calls are async. I imagine a pattern where the UA waits a turn of the event loop for the web-app to enumerate all its permission requests, then shows the dialog might work well. Some of the current permission request APIs (geoloc, Notification) are not Promise based, but imagine this.

Promise.all([
  Notification.requestPermission(), // Some shimmed form that returns a Promise
  navigator.push.hasPermission()
]).then(function(perms) {
  if (perms[0] == 'granted') { // notifications ok; }
  if (perms[1] == 'granted') { navigator.push.register(); }
});

from push-api.

anssiko avatar anssiko commented on August 13, 2024

@nikhilm Have you been experimenting with the idea further?

There's related discussion over at SysApps (http://lists.w3.org/Archives/Public/public-sysapps/2014Apr/0070.html), and the group is pondering whether to draft an API that would formalize the pattern, to be implemented by APIs that request permissions. Something along the lines of:

enum PermissionLevel {
  "default",
  "denied",
  "granted"
};

[NoInterfaceObject]
interface Permissions {
  Promise<PermissionLevel> requestPermission ();
  Promise<boolean> hasPermission ();
  /* ... */
};

Notification implements Permissions;
PushManager implements Permissions;
/* ... */
Geolocation implements Permissions;

WDYT?

from push-api.

millisecond avatar millisecond commented on August 13, 2024

The solutions proposed by @anssiko or the Promise based one @nikhilm outlined sound very workable. Is that even conceivably implementable in the same time-frame though?

If it's not and one permission didn't imply the other, "push" and "notifications" would essentially be split along "spec lines" that would greatly limit the functionality that already exists in the marketplace as a single unit.

It's like if "push notifications" also required a network permission to operate (clearly not in the same spec, but also clearly required).

from push-api.

nikhilm avatar nikhilm commented on August 13, 2024

I haven't thought about this at all :) I'm not a spec guy, this was just what I came up with off the top of my head.

from push-api.

anssiko avatar anssiko commented on August 13, 2024

@nikhilm I meant have you experimented with the idea in implementations (or have plans to)? Personally I feel this is a good proposal that would benefit from further experimentation in code.

As you probably know, the wider web community is currently looking at the permission solution space, and I feel this is good input to that discussion. I especially like the way how this could be retrofitted to many existing APIs without breaking backwards-compatibility. It would be too early to spec this feature yet though, we'd need feedback from implementers first.

Do you envision the Promise returned by requestPermission() to resolve with boolean (to indicate whether the request was granted or not), permission level of some sort (e.g. "default", "denied", "granted"), or something else? I updated the IDL sketch above to reflect the latter alternative.

from push-api.

mounirlamouri avatar mounirlamouri commented on August 13, 2024

I was pointed to this GH issue by Dave Raggett. I realise that you were sketching something close to what I proposed in public-webapps yesterday: http://lists.w3.org/Archives/Public/public-webapps/2014JulSep/0389.html

Note that we are not including requestPermission() in this proposal (contrary to what was sketched here) and we decided to go for a single entry point API instead of a pattern. There are also slight differences, including the ability to specify options when checking for a permission.

from push-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.