When using MultipeerConnectivity with ios 11, it is impossible to transmit lightweight size images

On iOS 11, I can not **send** a file of **light size** using Multipeer Connectivity.

However, on iOS 10, it was able to send regardless of size.

 

 

If it could not be sent, the block in “completionHandler” of “MCSession.sendResource (at: withName: toPeer: withCompletionHandler :)” was not called.

Probably, when the size is light, processing of the transmission status seems not functioning properly.

 

 

Even iOS 11, I was able to **receive** a file of light size.

 

 

What do I need to send a file of light size?

 

 

## Error Image

 

 

![MultipeerConnectivity Error Image](https://i.stack.imgur.com/YCqK1.png)

 

 

## Programing

https://github.com/amarron1/MultipeerGroupChatSwift/blob/master/MultipeerGroupChatSwift/SessionContainer.swift

 

 

    class SessionContainer: NSObject, MCSessionDelegate {

        var session:MCSession?

        var delegate:SessionContainerDelegate?

  

        func sendImage(imageUrl:URL) -> Transcript {

          

            var progress:Progress?

            // Loop on connected peers and send the image to each

            for peerID in (self.session?.connectedPeers)! {

                progress = self.session?.sendResource(at: imageUrl, withName: imageUrl.lastPathComponent, toPeer: peerID, withCompletionHandler: { (error) in

  

                    // **WAS NOT CALLED!!!**

                    if (error != nil) {

                        print(“Send resource to peer ” + peerID.displayName + ” completed with Error ” + error.debugDescription)

                    } else {

                        // Create an image transcript for this received image resource

                        let transcript:Transcript = Transcript().initWithPeerID(peerID: (self.session?.myPeerID)!, imageUrl: imageUrl, direction: .TRANSCRIPT_DIRECTION_SEND)

                        self.delegate?.updateTranscript(transcript: transcript)

                    }

                    // **WAS NOT CALLED!!!**

  

                })

  

            }

            // Create an outgoing progress transcript.  For simplicity we will monitor a single NSProgress.  However users can measure each NSProgress returned individually as needed

            let transcript:Transcript = Transcript().initWithPeerID(peerID: (self.session?.myPeerID)!, imageName: imageUrl.lastPathComponent, progress: progress, direction: .TRANSCRIPT_DIRECTION_SEND)

          

            return transcript

        }

    }

Powered by WPeMatico

About

You may also like...

Comments are closed.