ionic2                
            Notification Push envoyée et reçue
        
        
            
    Recherche…
Remarques
Le SenderID qui est présent dans l'exemple d'initialisation est un identifiant d'expéditeur gcm qui vous est donné par Google. Il devrait également être présent lorsque vous installez le plugin
ionic plugin add phonegap-plugin-push --variable SENDER_ID="XXXXXXX" 
Si vous souhaitez ajouter des données supplémentaires à vos notifications push, consultez ce lien en expliquant comment ajouter plus de caractères. Https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/TYPESCRIPT.md
Initialisation
Le plug-in de notification push nécessite une initialisation d'initialisation qui indique au plug-in de commencer à s'exécuter à l'aide de l'ID de l'expéditeur fourni.
  let push = Push.init({
      android: {
        senderID: "------------",
      },
      ios: {
        alert: "true",
        badge: true,
        sound: "false",
      },
      windows: {},
    });
enregistrement
L'étape d'enregistrement enregistre l'application avec le système de l'appareil et renvoie un identifiant d'enregistrement
 import { Push, RegistrationEventResponse} from "ionic-native";
        //the push element is created in the initialization example
        push.on("registration", async (response: RegistrationEventResponse) => {
                    //The registration returns an id of the registration on your device
                    RegisterWithWebApi(response.registrationId);
    
        });
Recevoir une notification push
Pour recevoir des notifications push, nous sommes supposés demander au plug-in d'écouter les notifications push entrantes. Cette étape est effectuée après l'initialisation et l'enregistrement
import { Push, NotificationEventResponse} from "ionic-native";
      
        //the push element is created in the initialization example      
        push.on("notification", (response: NotificationEventResponse) => {
            let chatMessage: ChatMessage = <ChatMessage>{
              title: response.title,
              message: response.message,
              receiver: response.additionalData.replyTo,
              image: response.image
            };
            DoStuff(chatMessage));
       });