Skip to content

Commit 9ab61a3

Browse files
committed
ステップ2「アプリにネイティブ機能をつけよう」
コアプラグイン「ローカル通知でユーザにお知らせしよう」
1 parent b7292f1 commit 9ab61a3

File tree

5 files changed

+24
-3
lines changed

5 files changed

+24
-3
lines changed

android/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
package="io.ionic.starter">
44

55
<application
6+
android:usesCleartextTraffic="true"
67
android:allowBackup="true"
78
android:icon="@mipmap/ic_launcher"
89
android:label="@string/app_name"

android/app/src/main/assets/capacitor.config.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@
33
"appName": "native-tutorial",
44
"bundledWebRuntime": false,
55
"npmClient": "yarn",
6-
"webDir": "www"
6+
"webDir": "www",
7+
"server": {
8+
"url": "http://192.168.0.17:8100"
9+
}
710
}

capacitor.config.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@
33
"appName": "native-tutorial",
44
"bundledWebRuntime": false,
55
"npmClient": "yarn",
6-
"webDir": "www"
6+
"webDir": "www",
7+
"server": {
8+
"url": "http://192.168.0.17:8100"
9+
}
710
}

src/app/tab1/tab1.page.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</ion-header>
88

99
<ion-content>
10-
<ion-card class="welcome-card">
10+
<ion-card class="welcome-card" (click)="localNotification()" button="true">
1111
<img src="/assets/shapes.svg" alt="" />
1212
<ion-card-header>
1313
<ion-card-subtitle>Get Started</ion-card-subtitle>

src/app/tab1/tab1.page.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Component } from '@angular/core';
2+
import { Plugins } from '@capacitor/core';
23

34
@Component({
45
selector: 'app-tab1',
@@ -9,4 +10,17 @@ export class Tab1Page {
910

1011
constructor() {}
1112

13+
localNotification() {
14+
Plugins.LocalNotifications.schedule({
15+
notifications: [
16+
{
17+
id: 1,
18+
title: 'ようこそ',
19+
body: 'Ionic Frameworkへ',
20+
schedule: { at: new Date(Date.now() + 1000 * 5) },
21+
sound: 'normail'
22+
}
23+
]
24+
});
25+
}
1226
}

0 commit comments

Comments
 (0)