react-native-push-notification icon indicating copy to clipboard operation
react-native-push-notification copied to clipboard

on press localNotificaton don't work on android

Open IsmetGlumcevic opened this issue 4 years ago • 6 comments

When calling localNotificationSchedule in context provider it works, when calling localNotificationSchedule onPress inside component it doesn't work on android. Ios work well.

MacBook air m1 react-native: 0.64 react-native-push-notification: 8.1.1 react-native-community/push-notification-ios: 1.10.1

index.js

   PushNotification.configure({
         onRegister: function (token) {
             console.log('TOKEN:', token);
         },
         onNotification: function (notification) {
            console.log('onnn', notification);
             notification.finish(PushNotificationIOS.FetchResult.NoData);
      },

  permissions: {
    alert: true,
    badge: true,
   sound: true,
   },
  popInitialNotification: true,
   requestPermissions: Platform.OS === 'ios',
  });
  PushNotification.createChannel(
  {
    channelId: 'local-notifications', // (required)
   channelName: 'Local-notifications channel', // (required)
   channelDescription: 'A channel to categorise your notifications', // (optional) default: undefined.
   soundName: 'default', // (optional) See `soundName` parameter of `localNotification` function
   importance: Importance.HIGH, 
   vibrate: true, // (optional) default: true. Creates the default vibration pattern if true.
   },
    created => console.log(`createChannel returned '${created}'`), 
    );`

Contex provider:

   useEffect(() => {
   PushNotification.localNotificationSchedule({
   id: '12333',
   channelId: 'local-notifications',
   title: 'Hat er sein Ziel erreicht 1',
   message: 'poruka',
    repeatType: 'minute',
   date: new Date(),
   });
  }, []);

component

 const setupNotification = (id, mess, name) => {
      PushNotification.localNotificationSchedule({
       id: id,
       channelId: `local-notifications`,
        title: name,
        message: mess,
       repeatType: 'minute',
         date: new Date(),
    });
  };

      <TouchableOpacity
              style={FormStyles.button}
              onPress={() => savePlane()}>
              <Text style={FormStyles.buttonText}>Einen Plan machen</Text>
     </TouchableOpacity>

IsmetGlumcevic avatar Nov 03 '21 16:11 IsmetGlumcevic

Hi @IsmetGlumcevic Your exemple is not complete, there is no call of setupNotification. Since it's working in useEffect, I suggest you to check again your code, probably undefined parameters Regards

Dallas62 avatar Nov 03 '21 16:11 Dallas62

I have id: '45id-45rr-33hf-34wd', which format can I put in id? I try with dot, comma.... There is function:

 let newId;
 id.split('').map((item, index) => {
  if (id.length - 1 > index) {
    newId += item.charCodeAt() + ',';
  } else {
    newId += item.charCodeAt();
  }
 });

IsmetGlumcevic avatar Nov 09 '21 21:11 IsmetGlumcevic

The fornat/type is described in the readme.

Dallas62 avatar Nov 09 '21 23:11 Dallas62

here dont working too

onPress call:

async function handleComplete() {
  console.log('test')
  PushNotification.localNotification({
    channelId: 'default-channel',
    title: 'testnotify',
    message: 'test'
  })
}

my config:

PushNotification.configure({
  permissions: {
    alert: true,
    badge: true,
    sound: true,
  },
  requestPermissions: false,
});

trindadematheus avatar Nov 12 '21 20:11 trindadematheus

@IsmetGlumcevic did you found a solution?

marcosfreitas avatar Oct 11 '22 18:10 marcosfreitas

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Feb 20 '24 00:02 github-actions[bot]