Importing and committing multiple PIM contacts collectively - blackberry

Can you import and commit multiple PIM contacts collectively? Currently we are importing and committing each contact individually, which results in the user having to authorise each contact.
This is our code:
PIMItem[] pi = instance.fromSerialFormat(inputStream, "UTF8");
Contact contact = contactList.importContact((Contact) pi[0]);
contact.commit();
Does anyone know how to do this?

You probably want to sign your application so the user gets the option to accept contact updates just once.

Related

CNContact unique id between devices

I'm having a bit of a problem with trying to access the same contact between multiple devices. My goal is to have a user select a contact and select a phone number and email address, which will then be stored in a database. If the user opens the app on another device, I would like to have the same contact selected.
I was hoping to use the CNContact.identifier for this case, but it appears that it is a device specific id. I could store the identifier for each device, but that would require the user matching contacts and that doesn't seam ideal.
This doesn't seam like it should be difficult but apparently I'm missing something. Thoughts?
The solution that seams to working for me is, I store the Contact identifiers, Address identifiers, Contact name, and the Address in my database. Then I take a mutli-step appoarch.
Search for Contact:
I attempt to find the contact based on the stored contact.identifiers I have already saved.
If I find 1 contact (identifier matched) => Great! I then attempt to match the found contact to my address.identifiers. Once again, if I find only 1 match, we're great! If not I then go to attempt to find an address (See below)
If I find no contacts (no identifiers matched) => I attempt to find the contact based on the Contact Name I had saved previously. If I do find a match, I then go to attempt to find the matching address (see below).
Search for Address:
Since at this point, I have a CNContact record that I believe matches, I look at each of their postalAddresses and compare it against the Street/city/state/zipcode/country that I have stored in my database.
If we find that perfect match, then I update my identifiers to include the new address/contact identifiers
If we ultimately don't find a match, I give the user an option to manually select the contact/address from their device.

How to get count of each unique firebase child so only the developer can see (not the user)

I am trying to figure out a way to get a list of each unique child in my Firebase Database & get a count of each unique child.
So for example if somebody entered Amazon 5 times an Hulu 2 times. I want to be able to know that. However, I don't want the user to know this.
I had a few ideas on how to do this.
Idea 1
Use Firebase's:
Answers.logCustomEvent...
However, I see two flaws with this idea.
Flaw 1: This wouldn't be useful for data that has already been entered.
Flaw 2: A user could enter Amason on accident and then changes it later to be the correct Amazon. I would get the incorrect entry..I could log changes but then I'd get bad data...or at least confusing data.
Idea 2
I could write a function inside of the app that could do this, but like I said. I don't need this functionality in the app for the user. I want it so I can know which sites I need to add functionality for first over ones that are seldom entered.
However, is it possible to have 2 apps that use the same database? So the main app is able to read and write data. While I could create a simple app that I wouldn't publish, only really use for myself that could Read the data but not write to it...
I tried to make my Database flat as I knew how..
When a user adds a service it doesn't go under the user node, I have a child called "services" and I just reference that service child in the "user" child.
So my database looks like this
cards
card uid 1
cardname: ""
services
service uid 1: true
services
service uid 1
serviceName: Amazon
serviceUrl: ""
service uid 2
serviceName: Amazon
users
... reference the card this user has access to
So to repeat the question.
I want to be able to know each unique serviceName and if there are duplicates of the same one..how many there are..
I don't need to know who created it or when..
you may have another table where you have objects with only 2 fields: serviceName and count.
So, everytime you have a new instance, you check if it already persists in your table and increment the count value, otherwise create a new row.
Users will not see that info.
And, yes, you can access one database from several apps. Just get clientID, trackingID, etc...

download a list users from twitter

I have a list of "n" Twitter ID representing users I would like to download.
To retrieve their user profile info, should I use n times the api call get_user or there exist a method to pass the entire list and retrieve all the info within one single api call, within the twitter rate time limit?
I tried something like
api.search_users(A)
api.search_users(id in A)
where A contains the list of id
but it does not work.
Anyone helping?
You can use the Twitter API resource https://dev.twitter.com/rest/reference/get/users/lookup. It can return user objects for at most 100 users at a time.
You can use this in Tweepy like:
user_objects = api.lookup_users(user_ids=list_of_at_most_100_user_ids)
Much of this answer first appeared as part of https://stackoverflow.com/a/42946854/1921546

Swift Firebase linking two nodes

I have an app and when a user creates an account it generates a uid for that user.
When the user continues to use the app and creates a card it will create a separate node under "cards" and generate a unique id for that card with a name and type of card. This is how I have done it
let card = ref.child("cards").childByAutoId()
card.setValue(["nickname": finalNickname, "type": finalType])
I am trying to link the nodes, I have been told to not put everything under one tree but to flatten it and have them be separate and then just link it.
This is what I have tried to do, with no success
ref.child("users").child((user?.uid)!).child("cards").child(card).setValue(true)
The problem that I am getting is that the .child(...) wants a String, and card is a FIRDatabaseReference.
Any ideas?
Your card variable is a FIRDatabaseReference. You're looking to get the key from it, so card.key:
ref.child("users").child((user?.uid)!).child("cards").child(card.key).setValue(true)
You could try this?
ref.child("users").child(user!.uid).child("cards").childByAutoId().setValue(["nickname": finalNickname, "type": finalType])
It is not really clear what you are exactly trying to do, could you provide more information

ABAddressBook: Is it possible to fetch the name of the Source?

I'm developing an app that has to retrieve all the contacts from the Address Book and display them according to the source (Gmail, iCloud, Outlook, Facebook ecc). I've already looked up all similar previous answer on this topic: has anybody found an answer?
Is it possible to discriminate between these sources (for example using mail addresses)?
Using kABSourceTypeProperty and kABSourceNameProperty seems not effective because two Gmail accounts will have same name and same type.
Furthermore is there a way to have a more significant name?
For now I have only names like this:
- name = "" (empty string) for Facebook contacts
- name = "Card" for iCloud contacts
- name = "Address Book" for Gmail contacts
- name = nil for Local Address Book, etc
If someone else is still stuck with this problem i found a trick solution for the sources of type kABSourceTypeCardDAV (such as Gmail and Yahoo accounts).
The trick is to access the kABPersonLastNameProperty of the ABRecordRef of the source even if it should be a ABPerson-only property. The result is a path (I think where the contacts are stored in the phone) that contains also the mail/name of the account.
Still no idea how to get the name of the account in the kABSourceTypeExchange case!

Resources