OneSignal integration (WIP) for iOS

This commit is contained in:
2023-08-27 08:41:33 +08:00
parent b5f1d9e0a7
commit 58be446511
26 changed files with 6080 additions and 3 deletions
+29 -1
View File
@@ -1,4 +1,5 @@
import { Component } from '@angular/core';
import OneSignal from 'onesignal-cordova-plugin';
@Component({
selector: 'app-root',
@@ -6,5 +7,32 @@ import { Component } from '@angular/core';
styleUrls: ['app.component.scss'],
})
export class AppComponent {
constructor() { }
constructor() {
this.OneSignalInit();
}
// Call this function when your app starts
OneSignalInit(): void {
// Uncomment to set OneSignal device logging to VERBOSE
// OneSignal.Debug.setLogLevel(6);
// Uncomment to set OneSignal visual logging to VERBOSE
// OneSignal.Debug.setAlertLevel(6);
// NOTE: Update the init value below with your OneSignal AppId.
OneSignal.init("13755f98-ec69-45fd-a2f1-d2166afcaa51");
let myClickListener = async function(event) {
let notificationData = JSON.stringify(event);
};
OneSignal.Notifications.addEventListener("click", myClickListener);
// Prompts the user for notification permissions.
// * Since this shows a generic native prompt, we recommend instead using an In-App Message to prompt for notification permission (See step 7) to better communicate to your users what notifications they will get.
OneSignal.Notifications.requestPermission(function(accepted) {
console.log("User accepted notifications: " + accepted);
});
}
}