zo0r / react-native-push-notification

React Native Local and Remote Notifications
MIT License
6.76k stars 2.05k forks source link

Custom Sound not found in react native > 0.60 in Android #1211

Closed cookienawer closed 4 years ago

cookienawer commented 5 years ago

Hi!

I was local notifications with localNotificationSchedule, but soundName only found with IOS

I found a solution for android in this fork: https://github.com/MaximusBaton/react-native-push-notification

But when I install this fork in ios crash the app...

It's my code:

react-native-cli: 2.0.1 react-native: 0.61.2

App.js

const App = () => {

  var PushNotification = require("react-native-push-notification");

  PushNotification.configure({
    // (optional) Called when Token is generated (iOS and Android)
    onRegister: function(token) {
      console.log("TOKEN:", token);
    },

    // (required) Called when a remote or local notification is opened or received
    onNotification: function(notification) {
      console.log("NOTIFICATION:", notification);

      // process the notification

      // required on iOS only (see fetchCompletionHandler docs: https://github.com/react-native-community/react-native-push-notification-ios)
      notification.finish(PushNotification.FetchResult.NoData);
    },

    // ANDROID ONLY: GCM or FCM Sender ID (product_number) (optional - not required for local notifications, but is need to receive remote push notifications)
    senderID: "YOUR GCM (OR FCM) SENDER ID",

    // IOS ONLY (optional): default: all - Permissions to register.
    permissions: {
      alert: true,
      badge: true,
      sound: true
    },

    // Should the initial notification be popped automatically
    // default: true
    popInitialNotification: true,

    requestPermissions: true

  });

Page with notification:

import PushNotification from 'react-native-push-notification';

class Registre extends React.Component {

  constructor(props) {
    super(props);

    PushNotification.localNotificationSchedule({
      //... You can use all the options from localNotifications
      smallIcon: "icon_black",
      soundName: "customnotify.mp3",
      message: "Hi!", // (required)
      date: new Date(Date.now() + 3 * 1000) // in 60 secs
    });

  }

Let's see if you can update the repository I fix it thanks.

phoenix377 commented 4 years ago

I've got the same issue - with remote notification coming from Firebase.

cookienawer commented 4 years ago

It seems that they do not answer the issues

LeVadim commented 4 years ago

Same issue here