【问题标题】:Maximum character count for local notification body - React Native iOS本地通知正文的最大字符数 - React Native iOS
【发布时间】: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

【问题讨论】:

标签: ios iphone react-native push-notification


【解决方案1】:

ascandroli 在这里回答了您的问题:What is the maximum length of a Push Notification alert text?

【讨论】:

    猜你喜欢
    • 2021-09-22
    • 1970-01-01
    • 2021-12-24
    • 1970-01-01
    • 1970-01-01
    • 2021-11-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多