Pu sh уведомления IOS реагируют на собственную ошибку NSDictionary - PullRequest
1 голос
/ 21 января 2020

Я использовал эту библиотеку для создания уведомлений pu sh в своем собственном приложении.

https://github.com/zo0r/react-native-push-notification.

Я пытался отправить локальное уведомление, код:

localNotif() {
    this.lastId++;
    PushNotification.localNotification({
      /* Android Only Properties */
      id: ''+this.lastId, // (optional) Valid unique 32 bit integer specified as string. default: Autogenerated Unique ID
      ticker: "My Notification Ticker", // (optional)
      autoCancel: true, // (optional) default: true
      largeIcon: "ic_launcher", // (optional) default: "ic_launcher"
      smallIcon: "ic_notification", // (optional) default: "ic_notification" with fallback for "ic_launcher"
      bigText: "My big text that will be shown when notification is expanded", // (optional) default: "message" prop
      subText: "This is a subText", // (optional) default: none
      color: "red", // (optional) default: system default
      vibrate: true, // (optional) default: true
      vibration: 300, // vibration length in milliseconds, ignored if vibrate=false, default: 1000
      tag: 'some_tag', // (optional) add tag to message
      group: "group", // (optional) add group to message
      ongoing: false, // (optional) set whether this is an "ongoing" notification

      /* iOS only properties */
      alertAction: 'view', // (optional) default: view
      category: null, // (optional) default: null
      userInfo: null, // (optional) default: null (object containing additional notification data)

      /* iOS and Android properties */
      title: "Local Notification", // (optional)
      message: "My Notification Message", // (required)
      playSound: false, // (optional) default: true
      soundName: 'default', // (optional) Sound to play when the notification is shown. Value of 'default' plays the default sound. It can be set to a custom sound such as 'android.resource://com.xyz/raw/my_sound'. It will look for the 'my_sound' audio file in 'res/raw' directory and play it. default: 'default' (default sound is played)
      number: '10', // (optional) Valid 32 bit integer specified as string. default: none (Cannot be zero)
      actions: '["Yes", "No"]',  // (Android only) See the doc for notification actions to know more
    });
  }

Я получил эту ошибку:

JSON значение типа NSNull не может быть преобразовано в NSDisctionary

1 Ответ

3 голосов
/ 21 января 2020

Попробуйте внести следующие изменения в JSON:

 category: null, // either pass a string here OR Remove this.
 userInfo: null, // either pass a JSON here OR Remove this.
 number: '10' // make this a number as 10 

Это может быть возможной ошибкой. Надеюсь, это сработает для вас.

...