Skip to content

Commit

Permalink
feat: request push permission
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile committed May 28, 2020
1 parent e4403e5 commit b586b34
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/app/home/home.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</ion-header>

<ion-content padding>
<ion-button (click)="register()" color="primary">register</ion-button>
<ion-button (click)="register()" color="primary">request permission and register</ion-button>
<ion-button (click)="getNotifs()" color="primary">get notifications</ion-button>
<ion-button (click)="removeNotifs()" color="primary">Remove notifications</ion-button>
<ion-button (click)="removeAllNotifs()" color="primary">Remove all notifications</ion-button>
Expand Down
10 changes: 8 additions & 2 deletions src/app/home/home.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,14 @@ export class HomePage {
}

async register() {
const result = await PushNotifications.register();
console.log(result);
const permResult = await PushNotifications.requestPermission();
if (permResult.granted) {
// Register with Apple / Google to receive push via APNS/FCM
const result = await PushNotifications.register();
console.log('register result', result);
} else {
alert(`push notifications won't work`);
}
}


Expand Down

0 comments on commit b586b34

Please sign in to comment.