From 1ef85ca8d74137f985d4b4a91915626aed0f64ff Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Wed, 31 Jan 2024 19:05:59 -0500 Subject: [PATCH] platform control --- src/app/pages/home/home.page.html | 2 +- src/app/pages/home/home.page.ts | 4 +--- src/app/services/onesignal.service.ts | 23 ++++++++++++++++------- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/app/pages/home/home.page.html b/src/app/pages/home/home.page.html index 1a1e851..477ef72 100644 --- a/src/app/pages/home/home.page.html +++ b/src/app/pages/home/home.page.html @@ -72,7 +72,7 @@ - + diff --git a/src/app/pages/home/home.page.ts b/src/app/pages/home/home.page.ts index fb89cae..dd1cbea 100644 --- a/src/app/pages/home/home.page.ts +++ b/src/app/pages/home/home.page.ts @@ -64,9 +64,7 @@ export class HomePage implements OnInit { allInitFunctions(){ if ( this.sessionDataProviderService.member_uid != ''){ - console.log("BLOG HOME 002->", this.blogDataService.blogData); - // this.firstname = this.sessionDataProviderService.firstname; - // this.onesignalService.Init(this.sessionDataProviderService.member_uid); + this.onesignalService.Init(this.sessionDataProviderService.member_uid); this.locTrcService.startTracking(); if (this.accountType == 'FULL'){ this.getBlogData([]); diff --git a/src/app/services/onesignal.service.ts b/src/app/services/onesignal.service.ts index 5df82e3..7a2accc 100644 --- a/src/app/services/onesignal.service.ts +++ b/src/app/services/onesignal.service.ts @@ -1,5 +1,7 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; +import { isPlatform } from '@ionic/angular'; + import { Observable } from 'rxjs'; //import 'rxjs/add/operator/map'; import { environment } from 'src/environments/environment'; @@ -23,17 +25,25 @@ export class OnesignalService { // Call this function when your app starts Init(member_uid): void { + if ( isPlatform('ios') == true || isPlatform('android')==true){ + console.log("Correct Notification platform"); + } + else{ + return; + } + // https://documentation.onesignal.com/docs/mobile-sdk - alert('OneSignalInit'); + // alert('OneSignalInit'); // 0 = None, 1 = Fatal, 2 = Errors, 3 = Warnings, 4 = Info, 5 = Debug, 6 = Verbose // Uncomment to set OneSignal device logging to VERBOSE - OneSignal.Debug.setLogLevel(6); - + //OneSignal.Debug.setLogLevel(6); + OneSignal.Debug.setLogLevel(0); // 0 = None, 1 = Fatal, 2 = Errors, 3 = Warnings, 4 = Info, 5 = Debug, 6 = Verbose // Uncomment to set OneSignal visual logging to VERBOSE //OneSignal.Debug.setAlertLevel(6); - OneSignal.Debug.setAlertLevel(4); + //OneSignal.Debug.setAlertLevel(4); + OneSignal.Debug.setAlertLevel(0); // NOTE: Update the init value below with your OneSignal AppId. OneSignal.init(this.AppId); @@ -43,16 +53,15 @@ export class OnesignalService { let myClickListener = async function(event) { let notificationData = JSON.stringify(event); - alert("CLICKED: " + notificationData); + //alert("CLICKED: " + notificationData); console.log('notificationOpenedCallback: ' + JSON.stringify(notificationData)); - }; OneSignal.Notifications.addEventListener("click", myClickListener); // Set a handler to run before displaying a notification while the app is in focus. let myForegroundWillDisplayListener = async function(event) { let notificationData = JSON.stringify(event); - alert("RECEIVED: " + notificationData); + // alert("RECEIVED: " + notificationData); console.log('foregroundWillDisplayCallback : ' + JSON.stringify(notificationData)); /// Display Notification, preventDefault to not display