Unique MSConversation.localParticipantIdentifier in iOS simulator - ios

When testing iMessage applications in the iOS simulator, retrieving the MSConversation.localParticipantIdentifier in the two default conversation threads (Kate Bell, John Appleseed) returns the same NSUUID string because we are still on the "same device".
To implement a turn based app, I am passing the localParticipantIdentifier with the URL data to keep track of the participants' turns.
Person 1 would pass his ID in the message to Person
Person 2 would compare passed ID to her own to determine if she made the last turn.
Is there a way to simulate a unique localParticipantIdentifier between the two test conversations on the iOS 10 simulator? Besides hardcoding the "turn" info for debugging, I cannot think of a way to simulate this real world condition. Thanks.
Note: I do not want to use MSMessage.senderparticipantidentifier because the sender does not necessarily determine who made the turn (ex: user sends a message that updates the app state but is NOT a "turn", 3+ person conversation thread, etc).

Personally I would use remoteParticipantsIdentifier from MSConversation.
So the idea is to keep a reference of the latest move with the id of who did the move, and allow the user to play if its id matches with the list of remoteParticipants (and if he is the next on that list).

Related

How would I be able to uniquely identify a contact in a contact store in a iOS device?

I need someway to uniquely identify a contact in contact store even if the contact is changed.
Is there a way to put code in iOS that is always watching in the background for the contact store to change? That way I can track a contact that I identify with a UUID value and make sure I can always match that specific contact with its UUID value even if the contact changes. If I put it in my app, then the user can close the app, and the app won't receive notifications when the contact store changes? Is there an app extension I can use that would allow me to do this, whether that is the intent of the extension or not?
Perhaps I can use key-value observing. Is it possible to observe the iOS Contacts app or the contacts store of a device using key-value observing? How would I find out? I can't find information on it when I do a search on Google.
I found information about the ABAddressBookRegisterExternalChangeCallback(::_:) function of the Address Book Framework, but that function has been deprecated, and only works with iOS 2.0–9.0. I don't see a function in the Contacts Framework that does what that function does.
Content Added Thursday, March 3, 2022, 12:03 AM:
I need the unique identifier to be saved in a record in a private iCloud database. The objective is to be able to query the database for the record associated with that contact. That would probably mean that the identifier would have to be unique across all iOS devices in existence.Is that so?

iOS real time 2 players app

I am currently writing an iOS real time game app auto-matchmaking function. I really need help to find out how can the two players can interact. Specifically, when plaeryA pressed the find match button indicating playerA is looking for a match. It sends a query to Parse database and sees that playerB is is also looking for a match. Now, I want them to be matched. I know it is a very bad idea to use queries to frequently polling the data from the database to check if the player is matched or not. Is there anyway I can achieve it such that 'if A and B is matched, a notification/alert is sent to both players to wait for their acceptance, if A & B both accepted the match, then the two players would perform the segue to the game view controller simultaneously.
I googled online, all I got is that I have to either use Apple's Game Center or Google Play service. But both of them requires users login. I do not really want that because it would be tedious user experience. The user had to register and sign in the account of my app, and now they have to sign in either game center or google again.
Any advice/help is greatly appreciated!!

Making a faux iPhone dialer

I want to make a joke application for a friend (not for general sale) that looks exactly like the iOS Phone application but so that whatever number is dialled into the application it appears to dial that number but actually dials a preset number in the background.
The way I figured to do it would be through the following:
User enters a number and hits the call button
Save the number entered as a contact's name and programmatically set the number of that contact as the preset number
Get the application to ring the preset number, to which it would switch over to the real iOS phone application and dial, but with it being a saved number in the contacts it will display the name, which is the number entered by the user.
Delete that contact upon re-opening the application as for it to not ask which number to dial the next time.
This is the only way that I can think of pulling this off, but it seems like it will look unconvincing; especially when it switches over to the real Phone application. Can anyone think of a better way? Such as calling from within the application?
I wouldn't usually take junk requests like this but it made me curious as to pull it off best.Thanks
If you are not going to publish this, then there is no reason why you shouldn't use private apis. See this answer (How to directly make a phone call with private API CTCallDial()?)

Get Contacts out of Address Book who also use the application

I'm developing my first iPhone-application in Xcode and I was wondering if it is possible to get the contacts out of the Address Book of the iPhone who also use the application?
So what I need is a way to generate a unique ID based on the information in the Address Book, so that the ID that will be constructed for the same person will be the same on every iPhone where the application is used.
This way, I can use this ID as a primary key in the database I use to hold data that needs to be shared among users.
If I can construct this idea, I can also compute the ID for every Address Book member and check them against the ID's in my database to see who uses the app. But how can I construct such a unique ID?
I am not sure.. accessing phone number in iPhone allowed or not ... as far as I know its not possible .. but in your application you can ask user to enter the his mobile number and then you can make phone number as unique ID... whatsapp is using the same thing ...
For getting phone number check this ..
How can I get the phone number of my iPhone device?
Programmatically get own phone number in iOS
How to get the phone number programatically

Notifications on remote change

I'm developing an application which holds a list of objects.
The user should be able to favorite some of these objects, which then gets saved for easy access. Simple enough, right.
However, in addition to that, I want it so that the application notifies the user (using a notification, like when you get a new SMS), whenever one of the favorited objects have had something changed (in my application the objects represent a pub, and a change to the pub is when it has a new event scheduled). The change is done on a remote server, using a webpage.
When my app is active I can just poll the server every few minutes and compare the properties of the object, and if I see a change notify the user.
But how will I do to make this work when my app is NOT in the foreground? I want the user to get a notification even if he/she is not currently running my app.
The app does not have any login-functionality, so I can't send out specific push notifications to specific users. So the only thing the server might have access to is perhaps the device ID. I.e. there is no real way for the server to know which favorites a device ID holds.
Is there some smart way to do this? On Android I can just use polling but as iOS doesn't allow code to run in the background in the same way I don't really know how to do.
All help greatly appreciated. Even if it's just a "I don't think that's possible".
Just create a table that associates device ID with favorites. When a favorite changes, send that device ID a push notification
The user is the device ID

Resources