Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Onesignal Header error How to solve #1245

Closed
chzappsinc opened this issue Jun 10, 2021 · 2 comments
Closed

Onesignal Header error How to solve #1245

chzappsinc opened this issue Jun 10, 2021 · 2 comments

Comments

@chzappsinc
Copy link

chzappsinc commented Jun 10, 2021

Description:

Error: {"errors": ["Please include a case-sensitive header of Authorization: Basic with a valid REST API key."], "reference": ["https://documentation.onesignal.com/docs/accounts-and-keys#section-keys-ids"]}

Where should I put header?

When I try this code below am getting this error

sendNotification = async (data) => {
  const { userId } = await OneSignal.getDeviceState();
    const notificationObj = {
      contents: { en: "Message Body" },
      include_player_ids: [userId],
      Authorization: "Basic APIKEYHIDED",
      headings: { en: 'You have new notification' },
      android_channel_id: 'id',
      template_id: 'id',
      buttons: [{ "id": "open_flat", "text": "OPEN HOSTING", "icon": "ic_menu_share" }],
      include_external_user_ids: ["13245-123455"],
    };
    const jsonString = JSON.stringify(notificationObj);
    OneSignal.postNotification(jsonString, (success) => {
      console.log("Success:", success);
    }, (error) => {
      console.log("Error:", error);
    });
      };
    //Sending demo 
    useEffect(() => {
        sendNotification()
      })

Environment

react-native-onesignal 4.1.1

Installed threw Yarn

@chzappsinc
Copy link
Author

Anyone please help!

@muhirwanto-dev
Copy link

Hi, what is the solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant