【发布时间】:2021-07-23 16:04:16
【问题描述】:
我已经在我的 React Native 应用中实现了本地通知。
使用react-native-push-notification-ios/push-notification-ios打包
我已尝试触发本地通知,并且成功了。但是本地通知不会显示正文的所有文本。显示全文的最大长度或任何解决方案?
我的代码:
showNotification = (id, title, message, data = {}, options = {}, channel) => {
console.log('SHOWWWWWW');
PushNotification.localNotification({
/* Android Only Properties */
...this.buildAndroidNotification(
id,
title,
message,
data,
options,
channel,
),
/* iOS and Android properties */
...this.buildIOSNotification(id, title, message, data, options),
/* iOS and Android properties */
title: title || '',
message: message || '',
playSound: options.playSound || false,
soundName: options.soundName || 'default',
userInteraction: true, // BOOLEAN: If the notification was opened by the user from the notification area or not
});
};
buildIOSNotification = (id, title, message, data = {}, options = {}) => {
return {
alertAction: options.alertAction || 'view',
alertBody: message || '',
category: options.category || '',
userInfo: {
id: id,
item: data,
},
};
};
更新的解决方案:
iOS 端最大字符长度为 256
【问题讨论】:
-
这是通知的“预览”。应该很短!如果您有更长的信息要传递,这里不是地方。
-
@matt 它只显示 256 个字符。我认为苹果限制了长度。任何解决方案
-
不客气 :)
标签: ios iphone react-native push-notification