Git Product home page Git Product logo

Comments (6)

micksabox avatar micksabox commented on July 20, 2024

+1
@seokgyo do you mean when the user declines to allow push notifications? I'm not sure if there is a way to detect this now, but it would be nice to know this. Passing null as a pushToken would be a good way to do it.

from react-native-onesignal.

seokgyo avatar seokgyo commented on July 20, 2024

The following is the current implementation for ios:

RCT_EXPORT_METHOD(idsAvailable:(RCTResponseSenderBlock)callback) { [oneSignal IdsAvailable:^(NSString* userId, NSString* pushToken) { NSLog(@"UserId:%@", userId); if (pushToken != nil) { NSLog(@"pushToken:%@", pushToken); NSDictionary *value = @{ @"pushToken": pushToken, @"playerId" : userId }; callback(@[value]); } else { NSLog(@"Cannot Get Push Token"); } }]; }

If pushToken is null, callback is not called. And the caller could not know what's going on. I don't know if there're some reasons for this. But in my opinion, callback should be called whether pushToke is null or not.

BTW pushToken is always null in iOS simulator.

from react-native-onesignal.

JonathanWi avatar JonathanWi commented on July 20, 2024

+1 for this feature: If the user register later during the process, I need to listen to the callback of his press (accept/decline) in order to move on to the next page.

from react-native-onesignal.

avishayil avatar avishayil commented on July 20, 2024

Hi, I won't be available on the next month to add new features. If you have any idea for a PR, i'll be happy to review it.
Hopefully after mid May i'll be back to add new features to this library.

I'll add this to the TODO list.

from react-native-onesignal.

avishayil avatar avishayil commented on July 20, 2024

Update to the latest package version, I fixed it and the callback is working in both iOS and Android.

The following code checks if the ids object is empty, if it is, console log "No Ids".

OneSignal.idsAvailable((ids) => {
    if (Object.keys(ids).length === 0 && ids.constructor === Object) {
        console.log("No Ids");
    }
});

Please re-open the issue if any problem occurs.

Thanks!

from react-native-onesignal.

JonathanWi avatar JonathanWi commented on July 20, 2024

Hey @avishayil I'm still not sure the case is closed:

If using OneSignal.registerForPushNotifications();, how do I know if a button has been pressed? OneSignal.addEventListener('ids', (device) => { ...}) allows me to know if the user pressed allow, but I have no way to know if the user declined the prompt...

Any idea on how to do that? I'd like to move the user to the next page after the selection has been made, but I'm only able to do that for the users that grant permissions.

Cheers!

from react-native-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.