fuse-open / fuselibs

Fuselibs is the Uno-libraries that provide the UI framework used in Fuse apps
https://npmjs.com/package/@fuse-open/fuselibs
MIT License
176 stars 72 forks source link

Push Notification: fix compatibility with latest Android #1478

Closed ichan-mb closed 1 year ago

ichan-mb commented 1 year ago

We also needed this PR: https://github.com/fuse-open/uno/pull/504 to make it works

Now, on Android 13 later, we can lazy request permission for push notifications same with iOS. First, define it on the unoproj

"Android": {
  "PushNotifications": {
      "RegisterOnLaunch": false
    }
}

and in your App, you can call the register method to ask for permission. Example:

<App>
    <JavaScript>

        var push = require("FuseJS/Push");
        var Observable = require("FuseJS/Observable")

        var log = new Observable()

        push.on("registrationSucceeded", function(regID) {
            console.log("Reg Succeeded: " + regID);
            log.value = "Reg Succeeded: " + regID
        });

        push.on("error", function(reason) {
            console.log("Reg Failed: " + reason);
            log.value = "Reg Failed: " + reason
        });

        push.on("receivedMessage", function(payload) {
            console.log("Recieved Push Notification: " + payload);
            log.value = "Recieved Push Notification: " + payload
        });

        module.exports.log = log
        module.exports.register = function() {
            push.register()
        }

    </JavaScript>
    <ClientPanel>
        <StackPanel>
            <Text Value="{log}" />
            <Button Text="Register Notification" Clicked="{register}" />
        </StackPanel>
    </ClientPanel>
</App>

This PR contains:

ichan-mb commented 1 year ago

I just did rebase, but is it correct? now it introduces so many previous commits and so many file changes, even though the changes are already in the repo

ichan-mb commented 1 year ago

I am sorry, this is bad PR, I am closing it. Please review the new one: https://github.com/fuse-open/fuselibs/pull/1479