Push Implemented! - Xmpp Not working (#506)
Closed
Unknown opened 3 years ago

Hi,

First all of thank you for this amazing chat library it is working very fine.

I have implemented VOIP push notification from my own server working fine, but when application removed from running or killed phone start ringing, able to accept or reject call but not connected to xmpp kindly help me i need your guidance.

Unknown commented 3 years ago
Unknown commented 3 years ago

@licaon-kter Where XEP-0357 covers VoIP? Siskin users custom extensions for push (including encrypted push notifications) to make VoIP work.

@uzairsabir When you receive a call from CallKit your app should be restored and you need to wait until it connects to XMPP server as this is required to establish VoIP connection.

Unknown commented 3 years ago

@hantu85 I thought it's that old Apple VOIP push that other apps were abusing before iOS13, ignore my ignorance as needed. :)

Unknown commented 3 years ago

@hantu85 "app should be restored and you need to wait until it connects to XMPP server as this is required to establish VoIP connection" How ? I am using the following code. forget the encryption and decryption for now:

func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) {

// RTCInitializeSSL(); // AccountSettings.initialize(); // XmppService.instance.initialize(); // CallManager.initializeCallManager();

    print(payload.dictionaryPayload)

    let json = JSON(payload.dictionaryPayload["acme2"]!)

    if let jsonArrayData = json.stringValue.data(using: .utf8){


    if let payload = try? JSONDecoder().decode(Welcome.self, from: jsonArrayData) {


        let _rid = payload[0].rid.replacingOccurrences(of: "\"", with: "")
        let _cid = payload[0].cid.replacingOccurrences(of: "\"", with: "")
        let _sid = payload[0].sid.replacingOccurrences(of: "\"", with: "")

        let account = BareJID(_rid)

        if let client = XmppService.instance.getClient(for: account) {

            let session = JingleManager.instance.open(for: client, with: JID(_cid), sid: _sid, role: .responder, initiationType: .message);

            let call = Call(account: account, with: JID(_cid).bareJid, sid: _sid, direction: .incoming, media: [.audio]);
            
            
            
           // call.session = session

            //print("Uzair_call_active_\(call.uuid)")
            //self.activeCalls.removeValue(forKey: call.key);

            self.reportIncomingCall(call, completionHandler: { result in
                switch result {
                case .success(_):
                    break;
                case .failure(_):
                    session.decline();
                }
                completion();
            });

        }else {
            self.endCall(on: account, with: JID(_cid).bareJid, sid: _sid, completionHandler: {
                print("ended call");
            })
        }

        completion();

        return;


    }

    }

         let uuid = UUID();
                let update = CXCallUpdate();
                update.remoteHandle = CXHandle(type: .generic, value: "Unknown");
                provider.reportNewIncomingCall(with: uuid, update: update, completion: { error in
                    if error == nil {
                        self.provider.reportCall(with: uuid, endedAt: Date(), reason: .remoteEnded);
                    }
                    completion();
                })

  
    
  
    
}
Unknown commented 3 years ago

@licaon-kter Apple has a few different kinds of pushes. Siskin uses "normal" push with high priority for messages and CallKit for VoIP.

XEP-0357 covers only how to send push to the component which will notify device, but does not specify a way to pass other data than sender jid, message body, or unread counter. Custom payload for sending other things (ie. kind of a VoIP call audio or a video) is not covered and required a separate extension.

Unknown commented 3 years ago

@uzairsabir When your app will be notified from CallKit that "user accepted to call", you need to "wait" for connection (XMPPClient for this account) to be in a connected state.

Unknown commented 3 years ago

i have tried the following code when "cancel call button is pressed from callkit" after receiving VOIP when app is killed. But unable to make connection please suggest something.

func reject() {

// DispatchQueue.main.async { // // guard XmppService.instance.getClient(for: self.account)?.state == .connected() else { // // return; // } // // if let client = XmppService.instance.getClient(for: self.account) { // // let _session = JingleManager.instance.open(for: client, with: self.jid, sid: self.sid, role: .responder, initiationType: .message); // // self.session = _session // // } // // } // guard let session = self.session else { self.reset(); return; }

    session.decline();
    self.reset();   

}
Unknown commented 3 years ago

You are not "waiting for reconnection", you just check if it is currently reconnected.

Unknown commented 3 years ago

@hantu85 how to reconnect would you like to share the code ?

Unknown commented 3 years ago

@hantu85 resolved by adding this code in my callkit delegate,

XmppService.instance.reconnect(client: client)

Thank you for your support.

issue 1 of 1
Issue Votes (0)
Watchers (0)
Reference
tigase/_clients/siskin-im#506
Please wait...
Page is in error, reload to recover