Integración OneSignal y configuración HTTP nativo

- Configurar OneSignal con nuevo App ID
- Agregar network_security_config.xml para permitir HTTP
- Habilitar CapacitorHttp nativo en capacitor.config.ts
- Actualizar SDK a Android 34
- Configurar API_URL fija (192.168.10.207:8080)
- Agregar onesignal.service.ts

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
CarlosTorres
2026-01-21 05:09:51 +00:00
parent dfcb1168b9
commit 103f7f45a0
11 changed files with 330 additions and 22 deletions

View File

@@ -9,6 +9,7 @@ import { LanguageService } from './services/language.service';
import { AlertService } from './services/alert.service';
import { TranslateService } from '@ngx-translate/core';
import { Capacitor } from '@capacitor/core';
import { OneSignalService } from './services/onesignal.service';
@Component({
selector: 'app-root',
@@ -29,9 +30,12 @@ export class AppComponent {
private events: EventService,
private alertService: AlertService,
private loadingCtrl: LoadingController,
private oneSignalService: OneSignalService,
) {
this.initializeApp();
this.events.subscribe('set_role', role => {
// Set OneSignal user tags when role is set (user logged in)
this.setupOneSignalUser(role);
if (role >= 2){
this.appPages = [
{
@@ -104,23 +108,32 @@ export class AppComponent {
await StatusBar.setStyle({ style: Style.Light });
await StatusBar.setOverlaysWebView({ overlay: false });
await StatusBar.setBackgroundColor({ color: '#0080ff' });
// TODO: Implement OneSignal with Capacitor plugin
// this.handlerNotifications();
// Initialize OneSignal push notifications
await this.oneSignalService.init();
}
this.languageService.getDefaultLanguage();
this.authService.getToken();
}
private async setupOneSignalUser(role: number) {
if (this.authService.token && this.authService.token.user_id) {
await this.oneSignalService.setUserId(this.authService.token.user_id);
await this.oneSignalService.setUserRole(role);
}
}
// When Logout Button is pressed
async logout() {
this.loading = await this.loadingCtrl.create();
await this.loading.present();
this.authService.logout().subscribe(
data => {
async data => {
this.alertService.presentToast(this.translateService.instant('alerts.logout'));
// TODO: Implement OneSignal tag clearing with Capacitor
// Clear OneSignal user tags on logout
await this.oneSignalService.logout();
},
error => {
this.loading.dismiss();
@@ -136,7 +149,4 @@ export class AppComponent {
async openUrl(url: string) {
await Browser.open({ url });
}
// TODO: Re-implement push notifications with OneSignal Capacitor plugin
// private handlerNotifications() { ... }
}