This project demonstrates the usage of OneSignal NPM package to add push notification to your Angular project.
Read our official how-to guide to demonstrate the usage of push notification using the OneSignal npm package and Angular.
Sign up for a free OneSignal account
NPM Packge: OneSignal-Ngx
npm i onesignal-ngx
import { OneSignalService } from 'onesignal-ngx';
Initialize OneSignal with your OneSignal AppId:
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'angular-example-app';
constructor(private oneSignal: OneSignalService) {
this.oneSignal.init({
appId: "YOUR-ONESIGNAL-APP-ID-HERE",
});
}
}
If you want to learn more about OneSignal data tags to segment your users, visti our official docs.
this.os.sendTag("tech", tag).then(() => {
console.log("Sent tag: " + tag);
});