[HELP] - How to setup OneSignal Push notifications

Hi, Koders! I just wanted to make a OneSignal push notification, here’s how to Do It.


1. Create New Project From Firebase

Creating a Project From Firebase, we will download the Account service JSON.


2. Tutorial Video

https://files.fm/u/d89emeg6ey


3. Description Help


First, go to OneSignal :onesignal: and create your new OneSignal :onesignal: Project
In the options, select Google Android (FCM)
Click Next
Then, import the Service Account JSON from the :firebase: Console.
To download the Service Account JSON, go to your new project, then click on the Gear (:gear:) icon, choose Service Accounts in The Tab, then scroll down and click: Generate New Private Key or download using these code languages.


Node.js

var admin = require("firebase-admin");

var serviceAccount = require("path/to/serviceAccountKey.json");

admin.initializeApp({
  credential: admin.credential.cert(serviceAccount)
});

Java

FileInputStream serviceAccount =
new FileInputStream("path/to/serviceAccountKey.json");

FirebaseOptions options = new FirebaseOptions.Builder()
  .setCredentials(GoogleCredentials.fromStream(serviceAccount))
  .build();

FirebaseApp.initializeApp(options);

Python

import firebase_admin
from firebase_admin import credentials

cred = credentials.Certificate("path/to/serviceAccountKey.json")
firebase_admin.initialize_app(cred)

Go

import (
  "fmt"
  "context"

  firebase "firebase.google.com/go"
  "firebase.google.com/go/auth"

  "google.golang.org/api/option"
)

opt := option.WithCredentialsFile("path/to/serviceAccountKey.json")
app, err := firebase.NewApp(context.Background(), nil, opt)
if err != nil {
  return nil, fmt.Errorf("error initializing app: %v", err)
}

While you finish downloading, go back to OneSignal, then select Upload File, choose the downloaded file, and after uploading, click Save and continue. Then, Copy the OneSignal App ID. Go back to Kodular and click the Gear Icon (:gear:) - Project settings, choose “API Keys” Section, then paste then, Paste the copied OneSignal App ID To the TextBox Called “OneSignal App ID”
And… Done!


And i will recommend the blocks, too (I Forgot to make it recommended.)

The REST API Key is same as API Key from OneSignal Dashboard.

Good Luck And Happy Koding! :wink:

@Ahmed_Islam1 is this guidance? if yes then make it more clear for newbies to understand it

@Ahmed_Islam1 if it is guide, then use guide category.

1 Like

OH NO I CANT CHANGE THE CATEGORY :sob::sob::sob:

@Ahmed_Islam1 Dont worry, @Taifun set/change the category.

One more thing to help better understanding of your guide, use screenshot & images and u may also use ai for better step by step guide for the newusers. :partying_face:

1 Like

Do we need a new project in firebase console? what about the existing project in firebase console If I’ve used firebase authentication? Because everytime I put Onesignal block, I get firebase authentication error? If I remove OneSignal blocks, I do not get any errors. Also, I tested sending PUSH notificatio via OneSignal dashboard it works, but my firebase auth breaks.

@Ibrahim_Jamar do you have any inputs to this issue? I’m new to Onesignal btw LOL

There’s a bug in something, i just don’t know which one may be. You may read something similar from this

In if you intend to use push notification, i recommend the @TimAi2 guides about web component as Authentication method whereby you wont use the Firebase.Authentication built in component. This will work, but changing of things/setup will be involved.

Also am working on something related to Firebase, but that can take a while to be released.

But for solution i may summon @Diego to investigate, whether the issue is with OneSignal/Firebase.Authentication

2 Likes

Thanks, thats what I was thinking at the end, becuase I tested both(Firebase Auth and OneSignal) separately and they worked. But when they are on the same project they crash. May be something developer team needs to be worked upon.
Also thanks for suggesting web component, I’ll try to make use of it for authentication.

1 Like

Great question, but Yes. you can make a new project and add your current app in your created Firebase Project.

will that fix the firebase authentication error? I already have the project and my app is tied to it. I dont think If I create another project, add both firebase and OneSignal content then firebase auth error fades away.

IDK But you may try it…

Hi! I’m having the same problem… I’d appreciate it if you could let me know if you have a solution…

Hey Jon, unfortunately there’s no solution to this issue. But the current workaround is to use Web component via REST, though I didn’t try this :pensive_face::pensive_face:

I tried onesignal with firebase authentication (REST) method and then it worked. The local FB authentication does not work with local onesignal component.

What is “FB”?

Firebase :laughing:

:rofl: seems like Ahmed didn;t go through complete post.

I AM BUSY RIGHT NOW…

So guys i’ll be quitting kodular, and switch to Appinventor, and Niotron.

Great choice :smiling_face_with_sunglasses: