Giter Site home page Giter Site logo

Comments (4)

pedro-lb avatar pedro-lb commented on July 28, 2024 1

Hey guys!

@emzoumpo @thedeephakani @m-dary-nur

Please try our new version, details here: #44

You'll need to change the initialization logic to set it up, but it should work much better ❤️

from react-onesignal.

pedro-lb avatar pedro-lb commented on July 28, 2024

Hey there @m-dary-nur , can you provide more details?

from react-onesignal.

thedeephakani avatar thedeephakani commented on July 28, 2024

same for me
when I try to add an event using the below code it shows me an error that callback is missing

 const events = [
            {
                listener: "once",
                event: "subscriptionChange",
                callback: async (isSubscribed: boolean) => {
                    if (true === isSubscribed) {
                        console.log("The user subscription state is now:", isSubscribed);
                    }
                },
            },
            {
                event: "notificationDisplay",
                callback: (event: any) => {
                    console.warn("OneSignal notification displayed:", event);
                },
            },
            {
                event: "notificationDismiss",
                callback: (event: any) => {
                    console.warn("OneSignal notification dismissed:", event);
                },
            },
        ];

Types of property 'callback' are incompatible.
Property 'callback' is missing in type '(isSubscribed: boolean) => Promise' but required in type 'IOneSignalEventCallback'

after that I try to write event like below

 const events = [
            {
                listener: "once",
                event: "subscriptionChange",
                callback: {
                    callback: (isSubscribed: boolean) => {
                        if (true === isSubscribed) {
                            console.log("The user subscription state is now:", isSubscribed);
                        }
                    },
                },
            },
            {
                event: "notificationDisplay",
                callback: {
                    callback: (event: any) => {
                        console.warn("OneSignal notification displayed:", event);
                    },
                },
            },
            {
                event: "notificationDismiss",
                callback: {
                    callback: (event: any) => {
                        console.warn("OneSignal notification dismissed:", event);
                    },
                },
            },
        ];

so now it does not display any error but the calls back function is not working

from react-onesignal.

emzoumpo avatar emzoumpo commented on July 28, 2024

@pedro-lb This is solved in #23 but it's not released yet as a new version. @m-dary-nur @thedeephakani The implementation above is correct with the types of the current version, but the types are wrong, and that's why it's not working
If you ts-ignore the error and use

{
    event: "notificationDismiss",
    callback: (event: any) => {
        console.warn("OneSignal notification dismissed:", event);
    },
},

it should work

from react-onesignal.

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.