Notifications et PushKit

Luc-ALuc-A Membre

Bonjour à tous !

Pour une application, j'ai besoin de mettre en place un appel vidéo et audio.
Bref, le souci est que l'application doit être réveillée lorsque un utilisateur appelle un autre utilisateur.

J'ai essayé d'implémenter PushKit dans l'AppDelegate, mais sans succès.
J'ai suivi ce tutoriel : http://www.nikola-breznjak.com/blog/ios/create-native-ios-app-can-receive-voip-push-notifications/
Mais ça ne fonctionne pas...

Je vous donne le code :

func setVoipRegister() {
    let voipRegistry = PKPushRegistry(queue: DispatchQueue.main)
    voipRegistry.desiredPushTypes = Set([PKPushType.voIP])
    voipRegistry.delegate = self
}




extension AppDelegate: PKPushRegistryDelegate {

    func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) {
        //print out the VoIP token. We will use this to test the notification.
        NSLog("voip token: \(pushCredentials.token)")
    }

    func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType) {
        print("didReceiveIncomingPushWith")
        let payloadDict = payload.dictionaryPayload["aps"] as? Dictionary<String, String>
        print(payloadDict ?? "PAS DE PAYLOAD")
    }

    func pushRegistry(registry: PKPushRegistry!, didReceiveIncomingPushWithPayload payload: PKPushPayload!, forType type: String!) {

        let payloadDict = payload.dictionaryPayload["aps"] as? Dictionary<String, String>
        let message = payloadDict?["alert"]

        //present a local notifcation to visually see when we are recieving a VoIP Notification

            DispatchQueue.main.async {

            }

           /*dispatch_async(DispatchQueue.main, { () -> Void in


            })*/
        //}

        NSLog("incoming voip notfication: \(payload.dictionaryPayload)")
    }

    func pushRegistry(registry: PKPushRegistry!, didInvalidatePushTokenForType type: String!) {
        print("token invalidated")
        NSLog("token invalidated")
    }

    func pushRegistry(_ registry: PKPushRegistry, didInvalidatePushTokenFor type: PKPushType) {
        print("token invalidated")
        NSLog("token invalidated")
    }
}

J'ai bien créé un certificat VOIP, et j'ai bien activé les background modes comme dans le tutoriel, mais je ne trouve pas la source de mon erreur.

Je vous remercie pour votre aide !

Mots clés:

Réponses

  • Luc-ALuc-A Membre

    Bonjour à tous !

    C'est résolu !! J'ai oublié de changer le token... :/ ...

Connectez-vous ou Inscrivez-vous pour répondre.