MultipeerConnectivity Pass Thumbnail Before Connecting - ios

I am trying to figure out a way to pass a thumbnail image between devices BEFORE the devices agree to connect.
Therefore I can not use the send data or send resource methods.
I can't pass it in the discoveryInfo as that would go over the discoveryInfo's size limit.
Yes I COULD store the image on a server and store a link to it in the discoveryInfo and pass that, but that isn't really an option (one for example, think about no internet connection)
The reason for this is I need to show the thumbnail of the user next to their name when they show up in the list.
(I am NOT using the standard peer picker window, but doing my own interface using MCNearbyServiceAdvertiser and MCNearbyServiceBrowser)
Does anyone have any ideas of how I could pass a thumbnail, or pass reference to a thumbnail that I can then have the app on their device then get, via standard controls/Multipeer/Bonjour/etc?
Thanks!

When you hear the nearby peer and invite them to join the session, you call
invitePeer:toSession:withContext:timeout:
The context is an "arbitrary piece of data that is passed to the nearby peer. This can be used to provide further information to the user about the nature of the invitation."
Presumably, you can include an NSData that contains a thumbnail image in the context.
You can exchange information at an earlier stage by providing discoveryInfo when creating the MCNearbyServiceAdvertiser. This is a dictionary of key-value pairs that are made available to browsers. However, you cannot use that for a thumbnail as "The key-value pair must be no longer than 255 bytes (total) when encoded in UTF-8".
To exchange larger amounts of data you need to create a custom discovery class using Bonjour for discovery.

Related

How to identify devices with HL7?

I am looking for HL7 messages by which I can identify the vendor and type of devices I have in my network (e.g. Medlink - Xray, Alaris - IV pump).
Are there any specific messages I should be looking at to achieve this?
Are the PRT segment and OBX-18 the relevant sources of information?
If would be much easier to answer if you could post a sample message that you have to deal with. But as a general practice you can follow below steps. You can use a application like HL7 soup to decode your HL7 messages. Please refer the below screenshot.
All the details related to the sender is encoded in MSH segment.
I am not aware about specific message for this but, I can see following workarounds:
Use MSH(2) (Sending Application) and MSH(3) (Sending Facility)
Data in these fields identify the sending application and facility. If this is configured different on each device, you can maintain a table in your database to map device against this data. This is only applicable if unique values for those fields are configured on each device.
Custom field in Z segment
This is only applicable if you can convenience the owner of device to manipulate/customize the HL7 message. Implement custom Z (ZDS may be) segment and define some field (ZDS(1) may be) with mutual communication and pass the device identifier in this field. You can then map this field in your database against device.
IP address on TCP level
If your communication is happening over TCP/IP, you may maintain a master table with device and IP address. Use this mapping to identify the device. You get IP address when the device connects to you.
These may not really be a solutions, just hacks - those also based on some pre-requisites.
Hope this helps you.

How bad is it to show Parse object id's to user?

I have a built in QR Code scanner in my iOS app. My backend runs on Parse, and I want the user to be able to pick certain objects on the app and encode their id's into a QR Code and share it around so that users can later scan a QR code, receive the object id's, and query them on the database to later fetch and display them somewhere.
However, what is stopping someone from using a QR scanner outside my app, looking at the object id's encoded into the QR, and messing something up? How bad is it to somehow allow users to see the object id of an entry in your Parse database? Will this heavily compromise security?
I thought about encrypting the object id's but am afraid my app will be rejected by Apple because of not following proper standards. What do you guys suggest?
Short answer: No.
There is no major security risk in giving away object IDs. Unless the 3rd parties had access to your app keys, then there is no way for them to access your data, even if they already knew everything about it. As long as you keep your app keys well hidden, there is no way your users can change anything outwith what you've de
Remember that your object ID's are only unique in the scope of your app (perhaps only even in the scope of that particular class), so when they find the object ID, they don't know if it's your app, my app, or anyone else's app - to them, it is as useful as holding a random set of digits.
The bigger issue I would say is that you cannot set the object IDs, so if for whatever reason that line is deleted, you can reinstate every part of it, but they'll all have different object IDs. This would mean your users running around with meaningless QR codes. Sure you can restore from a backup, but you'll lose any other changes since then. This is why I would never recommend indexing using Object IDs, rather that you create a new column "ID" that can then be changed by you, and then scripting a piece of cloud code logic in the side to ensure it is unique.
Sharing the object ID is not an issue, so long as your app has proper security. Hopefully your app's security does not rely on keeping the object ID secret.
Encryption is fine in iOS apps, so long as you file the proper paperwork. One of my apps uses a very high level of encryption and is available in every country, except France. You just need to file the correct paperwork and it's not that hard to do.

How to get User Data from the App?

Is there a way to get data from the user while they use my app on their device (iPhone/iPad). For example, if the app fills a dictionary during the runtime about which avatar is used most of the time and which avatar not, is there a way to transfer that dictionary to me? Do I need a server?
This is my first time thinking about data transfers over the internet. I don't have any idea or any experience on how to do that. Somehow I feel it is impossible for some security reasons. I found the NSURLConnection class, but this seems to be only one way to move data from a server to the app.
Thanks.
Not sure if I fully understand the question, but I am assuming you would like to get information about how the user is using your application?
This is definitely possible; and yes, you will need a server to send, retrieve or store the information that you require, or else there is no way to get the data from the application to you! You will need to learn how server side and client side web scripting works (if you do not know already) as this is how the application will communicate with your server.
Depending on the kind of information you are trying to retrieve, there may be security issues and Apple may not accept your application. However, if your data is specific to your application features, there should be no issue of this kind.
HTH

vCard's tag in URI

I need to upload Contact's information to the web server. I know that it can be done using HTTP PUT approach.
Also API from Address Book Programming guide, even some wrappers (such as RHAddressBook), allow us to generate NSData from Person's contact information.
I detected by WireShark how it is done on one of the servers.
For instance the part of URI for creating (uploading) vCard is this:
.../default/17b0dff5-5145-4515-85c0-5eb56f225f12.vcf
How to generate that tag (17b0dff5-5145-4515-85c0-5eb56f225f12)?
How it is calculated from vCard's data?
Dont know which server you are going to interact with but, in general, the last segment of the URI just need to be unique in the addressbook collection on the server. That is why many clients use some form of UUID.
In other words, the URI is not calculated from the vCard.

ios App improve network performance by requesting data up front

I have an application that I'm writing that pulls data from a few network sources:
1) list of blog posts (UITableViewController)
2) list of videos (UIViewController with an embedded UIScrollView)
3) list of images (UIViewController with an embedded UIScrollView)
Right now, there is a home screen with a menu and when you push one of the buttons, a destinationViewController (described above) is what loads the data on demand. I've noticed this is quite slow, especially when on a cellular data connection as opposed to wifi.
I was thinking about creating a class that requests all the data up front and kick it off every time the app is reentered. Does anyone have suggestions that could help me answer the following?
1) are there any classes, frameworks, or existing i code i can use to kick off these requests in a single place?
2) how do my destination view controllers (mentioned above) get the data?
3) how do my destination view controllers get informed that the data is ready if they happen to be invoked before the data is available?
4) is there a better strategy i should employ?
I appreciate the help.
Thanks,
jas
Off the top of my head, I would make the request class you mentioned and start all the request methods in applicationDidFinishLaunching in AppDelegate. I would also probably make custom NSObjects for each type of object you would be fetching and in each of your request class methods, convert the fetched data into said object, then cache each object to disk as they are downloaded. Then in your viewcontrollers, fetch the cached objects as needed.
When you are cacheing, make sure you cache each object with a key that will 100% be unique, because you are going to want to run a check on the current local cache before you start a new download. I would probably string together the file type and file name, and set that string as the key for the cached object.
To run the check on current cache in your request class methods, something that says "if current cache contains object for key:
uniqueKey... do nothing. If else, start the download and cache the object when finished."
Also run a check in your view controllers, because you're also going to want to handle the case where your view controller is requesting a cached object, but it hasn't downloaded yet. So something along the lines of "if current cache has object for key:key, great! use it. If else, start the download... cache it... then give me a call back here so i can use it while I display a loading message to the end user."
Im sure there are other scenarios that you are going to have to deal with, but that's the theoretical direction I would head in.
EDIT:
check out this, it will probably help you a lot. I think it also uses Ego Cache (if you dont want to write your own cache methods): https://github.com/Infusion-apps/Download-Manager
EDIT 2:
I also agree with #RyanDignards point #4. If possible, avoid fetching data you don't need. However, only you really know your UI/UX and app functionality, and my suggestion is assuming there is a good chance your end user is going to be using your app for the sole purpose of consuming the content you provide. So they are most likely going to be wanting to read the blog posts, watch the videos etc... The call is up to you, if you think there is more of a chance that the user will be viewing all the content than not, I would go the preload route, because nothing pisses off a user like having to wait.
1) RestKit is generally regarded as one of the the standard web interaction frameworks http://restkit.org
2) RestKit provides methods such as -[getObjectsAtPath: parameters: success: failure:] or post, which will provide the response in success. Additionally, it can convert the response directly into the respective objects for you with mapping.
3) Generally I would post a notification which is unique to that request, and any controller interested would get notified, with the response located on notification.object within the listener. Additionally most network requests provide for a callback handler where you could update the UI directly.
4) I would advise against preemptive loading since you're using resources for something that you may not actually use. My advice would be to breakdown your calls to the smallest possible level, then as the notifications are posted, that data would be inserted into the UI.

Resources