OneSignal / OneSignal-Cordova-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your Ionic, PhoneGap CLI, PhoneGap Build, Cordova, or Sencha Touch app with OneSignal. Supports Android, iOS, and Amazon's Fire OS platforms. https://onesignal.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug]: "Invalid action" message for any action (addTag, addAliases, requestPermission)

eirielson opened this issue · comments

What happened?

Hi, I'm migrating from version 3 to the latest release 5. After initialization, the device is successfully registered with OneSignal users, however, no other actions are performed successfully: addTags, listeners, option. All of these throw an "invalid action" exception. This way, tags are not updated in OneSignal, nor are external_ids, listeners to handle when pushes are opened are also not executed.
It seems to me to be a general instability in the library, any method other than "initialize" returns errors, even the methods for setting the Debug Level.

image

The second user registration is using the old API, version 3, which is why the Tag values are set
image

Steps to reproduce?

Lib version: "onesignal-cordova-plugin": "5.0.3"
I created some methods to call manually, to perform the initialize, add tags, listeners functions.
All of these actions below return an invalid action message.

initialize() {
        // This set return a error
        OneSignal.Debug.setLogLevel(6);

        OneSignal.initialize("...");

        let myClickListener = async function (event) {
            let notificationData = JSON.stringify(event);
            console.log(notificationData);
        };

        //invalid action
        OneSignal.Notifications.addEventListener('click', myClickListener);

        //invalid action         
        OneSignal.login("...");       
    }

    addTags() {
        OneSignal.User.addTags({
            key: "value",
            key2: "value",
        });

        OneSignal.User.addAlias('idek', idUserPush);
    }

    permission() {
        OneSignal.Notifications.requestPermission(true).then(s => {
            alert(s);
        });
    }
    optin() {
        OneSignal.User.pushSubscription.optIn();
    }

    optout() {
        let perm = OneSignal.Notifications.hasPermission();
        console.log(perm);
        console.log(OneSignal.User.pushSubscription.optedIn);
        
        OneSignal.User.pushSubscription.optOut();
    }


### What did you expect to happen?

I want to start the session, set a user's tags and external id and control the opening of pushes with their parameters.


### OneSignal Cordova SDK version

5.0.3

### Which platform(s) are affected?

- [ ] iOS
- [X] Android

### Relevant log output

_No response_

### Code of Conduct

- [X] I agree to follow this project's Code of Conduct

<!-- probot = {"onesignal-probot":{"response_time_in_business_days":1}} -->

How did you fix this?