Get contact details to titanium from native iOS contact app

喜欢而已 提交于 2019-12-08 06:27:59

问题


I'm new to Titanium. Currently I'm working on a project in this the user needs to use the contact details from iOS contacts App.

My app.js looks like this

Window = require('ui/handheld/ApplicationWindow');
var win = Window();
win.open();
var button = Ti.UI.createButton({
    title : 'Show Contacts',
    width : 100,
    height: 50,
});
win.add(button);
button.addEventListener('click',function(e){
    Titanium.Contacts.showContacts({ });
});

When I click on a button the following code is displayed:

And when I select an contact the detail is displayed on the other screen:

But I don't want this, When the user selects an individual contact the details should be passed to my app.js file. And no need to go to the details page.

Is there any way to do this ? Please help me. Thanks in advance.


回答1:


It seems that you're missing a declaration of function to be called when a person is selected:

Titanium.Contacts.showContacts({/*missing selectedPerson callback object*/});

You can read more on what parameters can be passed into showContacts method here.




回答2:


Finally I got it.

I used the following code:

button.addEventListener('click',function(e){
    Titanium.Contacts.showContacts(values);
});
var values = {cancel:function(){}};
values.fields = ['firstName', 'lastName', 'phone'];

values.selectedProperty = function(e) {
                var cn = e.person.firstName; 
                var sn = e.person.lastName;
                alert('Name'+cn+' '+sn);
};

Reference : Titanium Contacts




回答3:


var parms = {
animated : true,
selectedPerson : function(e) {
    alert(e.person);
}

}; Titanium.Contacts.showContacts(parms);

You will get the details of selected person in e.person object. that can be passed to app.js etc according to your requirements. i just showed it in the alert.



来源:https://stackoverflow.com/questions/14021114/get-contact-details-to-titanium-from-native-ios-contact-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!