小编b-a*_*saf的帖子

React Native moment.locale不起作用

我正在使用React Native版本0.45.1和当前版本2.18.1.

我正在尝试根据本地设备更改日期,但我总是在'en-Us'区域设置中获取日期.我无法导入所有语言环境,就像我在某些解决方案中看到的那样,因为我事先并不知道设备语言环境.(例如:https://github.com/moment/moment/issues/2962)

还有其他选择吗?

locale momentjs react-native

6
推荐指数
2
解决办法
6626
查看次数

反应本机推送通知声音

我正在尝试将声音添加到我的本地推送通知中.我正在使用RN 0.45.1和react-native-push-notifications 3.0.0

我设法使用默认声音在iOS和Android中安排通知.我没有设法添加自定义声音.

我有mp3类型的声音文件.我尝试了以下方法:

  1. 将文件放在我的项目文件夹中:'/ src /assests/sounds/sound.mps'(我的项目中的文件夹)

然后:

import notificationSound from '../src/assests/sounds/sound.mps';

PushNotification.localNotificationSchedule({
            message: 'Test message',
            date: new Date(Date.now() + (60 * 1000)),
            repeatType: 'time',
            repeatTime: 60 * 1000,
            sound: notificationSound,
        });
Run Code Online (Sandbox Code Playgroud)
  1. 另一个尝试是:将声音文件放在android文件夹下:..\android\app\src\main\res\raw\sound.mp3

通知是:

   PushNotification.localNotificationSchedule({
            message: 'Test message',
            date: new Date(Date.now() + (60 * 1000)),
            repeatType: 'time',
            repeatTime: 60 * 1000,
            sound: sound.mp3,
        });
Run Code Online (Sandbox Code Playgroud)

javascript push-notification react-native

5
推荐指数
1
解决办法
6268
查看次数