Hi Everyone,
Is there a framework or pattern to allow peer to peer communication between multiple iOS application?
The use case would be as follow:
An organizer creates a session with multiple users.
The users receive an invitation (initially via email or sms), they install the app, upon accepting the invitation, they join a session.
The session then allow peer to peer communication between users, not necessarily in the form of text messages, but more on information and synchronization between states of models between the members.
Is there a framework for such a communication, or are we forced to go through a server to relay messages?
I found the Multipeer communication Framework but it is for the discovery of devices, not for communication between applications.
Thanks a lot.
Post
Replies
Boosts
Views
Activity
Hi,
I try to add the Firebase requirements to my iOS application.
I launched the package manager, at first, nothing was loading, therefore I deleted and recreated my Github account, and the previous packages now appears.
When I try to paste the url for Firebase in the search bar, there is an infinite loading loop and it never appears.
I tried to restart Xcode several times, to disconnect and reconnect from wifi etc.
Can anyone help me solve this please?
Hi,
I created a leaderboard in my application, and a method to record a new score:
GKLeaderboard.loadLeaderboards(IDs: [leaderboardID]) { (leaderboards, error) in
if let error = error {
print("Error loading leaderboards: \(error.localizedDescription)")
}
guard let leaderboard = leaderboards?.first else {
print("Leaderboard not found")
return
}
leaderboard.submitScore(score, context: 0, player: self.localPlayer) { error in
if let error = error {
print("Error reporting score: \(error.localizedDescription)")
} else {
print("Score reported successfully!")
}
}
}
}
When debuging, this method is correctly called and I have a success, so I tried to test it with an internal TestFlight release.
The leaderboard is never updated.
Is there a way to perform a test of a leaderboard before publishing the app?
I have the same question for achievements:
let achievement = GKAchievement(identifier: identifier)
achievement.percentComplete = percentComplete
GKAchievement.report([achievement]) { error in
if let error = error {
print("Error reporting achievement: \(error.localizedDescription)")
}
}
}
Thanks!
Hi,
I'm trying to implement a way to share a phone number from call logs with my app.
I would select the call log entry, then "share contact" and share to my app.
I implemented a Share Extension and my application appears in the list of application to share with.
How can I list my application in the list of actions below the app icons?
When I share with my app, the Share Extension view shows up, but no action is possible: I implemented a button to be able to send the number to my application but the action never fires, is it the correct implementation?
How would I implement the sharing of the number with my main app? I tried with a custom url binding but I'm not sure if it is the correct way. My ideal implementation would be that no view show up and my application is immediately launched and the number is pasted.
struct ShareView: View {
var extensionContext: NSExtensionContext?
@State private var contact: CNContact? = nil
@State private var error: Error? = nil
@State private var multiSelection = Set<String>()
@State private var selectedPhoneNumber: String? = nil
var body: some View {
NavigationStack {
VStack() {
if let contact = contact {
Button(action: submitPhoneNumber) {
Text("Submit")
.padding()
.background(Color.green)
.cornerRadius(8)
.foregroundColor(.white)
}
List(contact.phoneNumbers, id: \.self) { phoneNumber in
Button(action: {
print("Phone number selected: \(phoneNumber.value.stringValue)")
self.selectedPhoneNumber = phoneNumber.value.stringValue
}) {
Text(phoneNumber.value.stringValue)
//.padding()
.background(self.selectedPhoneNumber == phoneNumber.value.stringValue ? Color.blue : Color.clear)
//.cornerRadius(8)
.foregroundColor(.black)
}
}
} else if let error = error {
Text("Error: \(error.localizedDescription)")
} else {
Text("Loading...")
.onAppear {
loadContact()
}
}
}
}
.padding()
.navigationTitle("Number")
.toolbar() {
Button("Close") {
close()
}
}
}
func close() {
NotificationCenter.default.post(name: NSNotification.Name("close"), object: nil)
}
private func isButtonActive() -> Bool {
return selectedPhoneNumber != nil
}
private func submitPhoneNumber() {
print("Selected phone number: \(self.selectedPhoneNumber ?? "Nothing")")
guard let phoneNumber = self.selectedPhoneNumber else { return }
guard let extensionContext = self.extensionContext else { return }
print("PhoneNumber: \(phoneNumber)")
let urlScheme = "callclean://"
if let url = URL(string: "\(urlScheme)?phone=\(phoneNumber)") {
print(url.absoluteString)
extensionContext.open(url, completionHandler: nil)
}
close()
}
private func loadContact() {
guard let extensionContext = extensionContext else { return }
for item in extensionContext.inputItems {
if let inputItem = item as? NSExtensionItem {
if let attachments = inputItem.attachments {
for provider in attachments {
if provider.hasItemConformingToTypeIdentifier("public.vcard") {
provider.loadItem(forTypeIdentifier: "public.vcard", options: nil) { (data, error) in
if let error = error {
DispatchQueue.main.async {
self.error = error
}
return
}
if let data = data as? Data {
do {
//let contactStore = CNContactStore()
let contacts = try CNContactVCardSerialization.contacts(with: data)
DispatchQueue.main.async {
self.contact = contacts.first
}
} catch {
DispatchQueue.main.async {
self.error = error
}
}
}
}
}
}
}
}
}
}
}
Thanks for your guidance.