1. Agora com o método de criar notificação funcionando, nós podemos linkar ele ao nosso “createHabit”, para criarmos ao mesmo tempo a notificação e o hábito.

“Pages → HabitPage → index.jsx”

import NotificationService from "../../services/NotificationService";

// ...

function handleCreateHabit() {
 if (habitInput === undefined || frequencyInput === undefined) {
   Alert.alert(
     "Você precisa selecionar um hábito e frequência para continuar"
   );
 } else if (
   notificationToggle === true &&
   frequencyInput === "Diário" &&
   timeNotification === undefined
 ) {
   Alert.alert("Você precisa dizer o horário da notificação!");
 } else if (
   notificationToggle === true &&
   frequencyInput === "Diário" &&
   dayNotification === undefined &&
   timeNotification === undefined
 ) {
   Alert.alert(
     "Você precisa dizer a frequência e o horário da notificação!"
   );
 } else {
   if (notificationToggle) {
     NotificationService.createNotification(
     habitInput,
     frequencyInput,
     dayNotification,
     timeNotification
     );
   }
   HabitsService.createHabit({
     habitArea: habit?.habitArea,
     habitName: habitInput,
     habitFrequency: frequencyInput,
     habitHasNotification: notificationToggle,
     habitNotificationFrequency: dayNotification,
     habitNotificationTime: timeNotification,
     lastCheck: formatDate,
     daysWithoutChecks: 0,
     habitIsChecked: 0,
     progressBar: 0,
   }).then(() => {
     Alert.alert("Sucesso na criação do hábito!");
	
     navigation.navigate("Home", {
       createdHabit: `Created in ${habitArea}`,
     });
   });
  }
}

// ...
  1. Ao fazer isso, nós podemos testar a notificação. No android studio pode vir um erro dizendo que é para usar o smarthphone, porém você receberá a notificação mesmo assim. Porém eu recomendo que você use o smarthphone, para que veja a notificação de fato aparecer.
  2. Um teste bom é criar um hábito diário com notificação marcada para o minuto seguinte, exemplo: São 21:00 agora, você pode colocar o horário da notificação de 21:01 ou 21:02, e esperar para ela aparecer.