質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.46%
React Native

React Nativeは、ネイティブモバイルアプリ(iOS/Android)を作成できるJavaScriptフレームワークです。Reactと同じ設計のため、宣言的なコンポーネントでリッチなUIを開発することが可能です。

Q&A

解決済

1回答

1109閲覧

expoのscheduleNotificationの設定【TransformError SyntaxError】

ok09

総合スコア11

React Native

React Nativeは、ネイティブモバイルアプリ(iOS/Android)を作成できるJavaScriptフレームワークです。Reactと同じ設計のため、宣言的なコンポーネントでリッチなUIを開発することが可能です。

0グッド

0クリップ

投稿2020/09/30 09:31

Expoで通知アプリを作っています。
triggerで毎週水曜日17時40分に通知をする設定を作ったのですが、以下のエラーが表示されました。

TransformErrorSyntaxError: /Users/user/Development/GomiApp/screens/HomeScreen.js: Unexpected token, expected ";" (16:44)

react

1import { StatusBar } from 'expo-status-bar'; 2import React from 'react'; 3import GomiList from "../components/GomiList"; 4import { StyleSheet, Text, View } from 'react-native'; 5 6import * as Notifications from 'expo-notifications'; 7 8Notifications.setNotificationHandler({ 9 handleNotification: async () => ({ 10 shouldShowAlert: true, 11 shouldPlaySound: false, 12 shouldSetBadge: false, 13 }), 14}); 15 16const trigger = CalendarNotificationTrigger { 17 type: 'calendar'; 18 repeats: true; 19 dateComponents: { 20 hour: 17; 21 minute: 40; 22 weekday: 3; 23 calendar: Calendar.current; 24 }, 25}; 26 27 28Notifications.scheduleNotificationAsync({ 29 content: { 30 title: 'ゴミ出しの時間です!', 31 }, 32 trigger, 33}); 34 35export default function HomeScreen() { 36 return ( 37 <View style={styles.container}> 38 <View style={styles.GomiList}> 39 <GomiList title="燃えるごみ"/> 40 </View> 41 <View style={styles.GomiList}> 42 <GomiList title="燃えないごみ"/> 43 </View> 44 </View> 45 ); 46} 47 48const styles = StyleSheet.create({ 49 container: { 50 flex: 1, 51 backgroundColor: '#fff', 52 }, 53 GomiList: { 54 paddingTop: 20, 55 alignItems: 'center', 56 }, 57}); 58

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

javascript

1const trigger = CalendarNotificationTrigger { 2 type: 'calendar'; 3 repeats: true; 4 dateComponents: { 5 hour: 17; 6 minute: 40; 7 weekday: 3; 8 calendar: Calendar.current; 9 }, 10};

上記のCalendarNotificationTriggerが不要だと思います。
また、ここで定義したtriggerNotifications.scheduleNotificationAsyncの引数で使われていますが、その場合型が違うと思います。
triggerにはCalendarNotificationTrigger型ではなくNotificationTriggerInput型が入るはずです。
以下、参考です。

投稿2020/09/30 14:07

nekoniki

総合スコア2411

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.46%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問