Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have been trying for multiple hours to find a way to send a global variable from the Apple Watch to the iPhone.
There are a lot of questions abut transferring data from iPhone to Apple Watch but not vice versa in Swift 3.
This is not a duplicate because I want to transfer data from the Apple Watch to iPhone, not vice Versa.
How can I do this?
Transferring data from Apple Watch to iPhone is very similar to vice versa.
For global variable you probably should use updateApplicationContext() of WCSession:
let session = WCSession.default()
if session.activationState == .activated {
session.updateApplicationContext(["my_global": g_myGlobal])
}
On the iPhone you should assign delegate to the default WCSession and activate it. In the WCSessionDelegate, implement the following method:
func session(_ session: WCSession, didReceiveApplicationContext applicationContext: [String : Any]) {
let receivedGlobal = applicationContext["my_global"] as? TypeOfTheGlobal
}
Alternatively you can use sendMessage(_:replyHandler:errorHandler:) but this will require iPhone to be reachable.
In general I would recommend you to follow Zak Kautz advice and read about WatchConnectivity. This is the most common way to communicate between watch and phone.
Using the watch connectivity framework, you can implement two-way communication.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 months ago.
Improve this question
I am working on a MacOS cocoa application using swift from which i have to send information using an object to another application on different machine which then use the information in it's code.
I am new to swift and sorry for my english if you don't to get it.
I have no idea how to do this. Please help me with this if anyone knows.
Well just so you know network communication can be pretty hard. I believe the easiest way is to use WebSocket, which establish a pipe of communication between two devices. You can then send any data you want over this socket.
One difficulty is for the devices to find one another : do they know each other's IP address ? Are they on the same local network ?
The second step is to decide what data you want to send. The simplest is to send JSON content which can be serialized / deserialized on each end easily.
Checkout :
tutorial for websocket
JSON Serialization
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm trying to build a swift app that would allow a user on one side to draw an image that will be updated in nearly real time on the other user's device, somewhat as if they were drawing on a whiteboard in person.
Anyone have any tips or places where I should start? I'm relatively new to swift. Thanks for your help.
This requires a persistent line of communication between your mobile device(s) and your server. Websockets allow this type of communication. I haven't implemented them myself so I can't provide implementation details, but there are plenty of resources available online.
Sockets with Swift
Websockets Tutorial
I think Realm is exactly what you are looking for.
Real time collaboration in as little as 10 lines of code
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I'm doing enterprise application. I need to detect last call duration from my application. I gone through core telephony framework but it will work only upto iOS 4.0. Can you please give me proper guidance to solve my problem.
Thanking you
Unfortunately you can't access the call history. The only User Data you have API access to is the address book. You can also access photos/pictures but only by starting an iPhone-controlled dialog that allows the user to choose a single image.
Note :-A CTCarrier object gives you information about the user’s cellular service provider, such as whether it allows use of VoIP (Voice over Internet Protocol) on its network. A CTCall object gives you information about a current call, including a unique identifier and state information—dialing, incoming, connected, or disconnected.
Read Link :-
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm Curious about how all the ad mechanism works.
Let's say I publish my app using 5 networks (adMob,inMobi, etc...).
Each network gives me a slice of code to incorporate inside my initialization function, so
when the app is downloaded, the report will be sent.
Now, someone downloaded my app using one of these networks, let's say by pressing an adMob banner.
Is there a way for my app to know at startup that it was downloaded using adMob, so I won't call all the other 4 network initialization code? I don't see a point making all these redundant calls.
Thanks
Well if it is an iPhone/iOS app it's always downloaded via iTunes App Store so there is no way to see which banner network is just to download your app.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I'm trying to write an application for the iPhone where the user will be notified of events such as deadlines. I am looking to override the silent mode and possibly have the notification sound loop until the user activates the application. Any info or documentation would be appreciated.
Thanks.
Overriding the OS sound settings in this manner, even if it were possible, would surely result in rejection during the review stages (if the reviewer caught this behaviour).
Think about what you're doing, and ask yourself if you think your user would appreciate this "feature". To me, the answer is clearly no.
Apple tends not to permit activities that could be so easily used to abuse the user. If I enable silent mode, there's a reason.
I'll give a tip on how I solved this problem, which may be a little different.
I was building an app where I wanted the user to be able to preview an MP3 clip, even if they had the phone on silent.
The way I went about this was first, importing the Audiobox framework <AVFoundation/AVFoundation.h> at the start of your file and then later in my code before I initialized my AVAudioPlayer I did:
[[AVAudioSession sharedInstance]
setCategory: AVAudioSessionCategoryPlayback
error: nil];
Worked like a charm. It may not be what the OP needed, however.