Trigger the native contacts ui in phonegap [ios] - ios

I've been looking through the documentation for the Contacts API and there are ways to retrieve and save contacts to display them on your own UI.
But is there any way to trigger the native contacts to display your address book?
Something similar to the SMS plugin which pops up the native sms composer within the app.
Thanks

I was looking for the exact same thing and came across this http://fqnow.com/phonegap-contact-picker/. Here's the Javascript code, all you need to do is:
function contactChooser(){
var options = new ContactFindOptions();
options.fields = ["displayName", "name", "emails", "phoneNumbers"];
navigator.contacts.chooseContact( onSuccess, options);
}
function onSuccess(id, contact){
alert(id);
alert(contact);
}

Related

"Internal" Error When Submitting Form With Firebase onCall Function on IOS Safari

I am trying to submit a form but I get an "internal" error after submit on IOS Safari. Happened on two separate devices. I'm using Firebase functions onCall function. Client code:
var contactForm =
window.firebase.functions().httpsCallable('contactForm');
let result = await contactForm({ accountUID, foldersFilter,
firstName, lastName, email, cellNumber, dobDay, dobMonth })
And server code:
exports.contactForm = functions.https.onCall(( data, context ) => {
return contactForm.contactForm( data, context )
});
This function is called via form. The form works great on chrome, safari desktop, but for some reason it gets an internal errror sometimes when testing on IOS device. At first I thought it only happened when I was using autofill, but I've tested more and I get the same error when not using autofill too.
The confusing thing is my function code is actually never being called (I don't see any firebase function logs). Here is my console in safari:
The network connection was lost.
Fetch API cannot load https://us-central1-projectId.cloudfunctions.net/contactForm due to access control checks
Failed to load resource: The network connection was lost.
internal
Why won't this form submit on ios safari?
I fixed the issue. Turns out it has something to do with Google Cloud Functions being IPv4, and Safari requiring IPv6. I suspect this will become a bigger issue moving forward. I'm having to move all onCall Firebase functions to https triggers. In order to make https triggers work, you have to use a custom domain in Firebase hosting and rewrite to your function endpoint.
{
"hosting": {
...
"rewrites": [
{
"source": "/api/contactForm",
"function": "contactForm"
}
}
and so now instead of calling https://us-central1-projectId.cloudfunctions.net/contactForm to trigger my api. I call https://customdomain.com/api/contactForm

How to show data changes locally before it updated and showed up in firestore

I'm following a tutorial for an chat app with flutter and firebase firestore. In that app when user sends a text message to other it's not visible to sender till it's get updated in firestore and then the new data is showing up in the messages list. I want to is it possible to add the newly sent message to the messages list with a clock image indicating that it will update in database and then after it's updated in database then locally added message should be replaced with data from firestore in messages list.
Here is snippet of button press to send message...
void onSendMessage(String content, int type) {
// type: 0 = text, 1 = image, 2 = sticker
if (content.trim() != '') {
textEditingController.clear();
var documentReference = Firestore.instance
.collection('messages')
.document(groupChatId)
.collection('message')
.document(DateTime.now().millisecondsSinceEpoch.toString());
Firestore.instance.runTransaction((transaction) async {
await transaction.set(
documentReference,
{
'idFrom': id,
'idTo': peerId,
'timestamp': DateTime.now().millisecondsSinceEpoch.toString(),
'content': content,
'type': type
},
);
});
listScrollController.animateTo(0.0,
duration: Duration(milliseconds: 300), curve: Curves.easeOut);
} else {
Fluttertoast.showToast(msg: 'Nothing to send');
}
}
and here is the link to the tutorial Chat app with flutter and firestore
This shouldn't be too difficult to achieve.
Currently any new chat message is sent to the Firestore database upon submission.
You just need to extend the onSubmit function that does it (it probably has another name in your code example) to also add the message temporarily to the local message list.
Once you receive the update from the database you just have to remove the temporary message from the list since it will be replaced with the contents from the database. Include the progress indicator with the temporary message and you're done.
If you need a more detailled answer please add some code to your question (ideally together with a link to the original tutorial. Note: When providing a link to an external page make sure that you question is still complete should the link go dead.)
I used a cloud function to achieve this. I have a field isSent on my message and it's initially false, when the message gets created in firestore, I then update the isSent field using the cloud function and that automatically rebuilds the UI. It's not very fast and accurate, but much better than none

Fitbit.Net 2.2 Activity log

My project is MVC 5, I am using Fitbit.Net library to access user Fitbit's data. Is there a way to get the activity name and duration?
I tried
var stats = await fitbitClient.GetDayActivityAsync(DateTime.Today, null);
I get the following:
The problem was the logged activity was not one of the common Fitbit activities so it did not show up. However, if the activity is a common, it works.

Appcelerator facebook login button events not working with alloy

I am using the alloy framework with appcelerator titanium and have done like this:
alloy.js
Alloy.Globals.Facebook = require('facebook');
Alloy.Globals.Facebook.permissions = ['public_profile'];
index.js
Alloy.Globals.Facebook.addEventListener('login', function(e) {
if (e.success) {
Ti.API.info("VALID FACEBOOK LOGIN");
var token = Alloy.Globals.Facebook.accessToken;
Ti.API.info("*** fb accessToken: "+token);
}
else{
Ti.API.info("FAILED FACEBOOK LOGIN...");
}
});
index.xml
<LoginButton id="fbButton" module="facebook" />
When i try to login using the button, the login is okay, and the facebook button changes to "logout" instead. However, no login event is ever fired and the evenlistener in index.js never gets anything.
What is causing this? Should i add the event lister in some other way?
iOS on device 9.3.1
Titanium SDK 5.2.2.GA
As pointed out in an earlier comment to the question the module was not initialized. Adding the initialize() line into my alloy.js seems to fix the problem, now i receive the login events.
in alloy.js
Alloy.Globals.Facebook = require('facebook');
Alloy.Globals.Facebook.permissions = ['public_profile'];
Alloy.Globals.Facebook.initialize();
i think you forget to add this instruction :
Alloy.Globals.Facebook.authorize();
As an ugly workaround until events gets fixed i simply added a setInterval that polls if Alloy.Globals.Facebook.loggedIn is true or not and then do the appropriate codes that should have been inside the event handler...
After submitting the app to app store, for some reason the reviewers could not get any events... this is really bad. It works in my simulators and on my device, but not for the submitted app when they test it...
No idea what to do really...

Facebook plugin for phonegap ios application - share on the wall

I am trying to share from my phonegap ios application. I use this code to post to my facebook wall
var facebookConnectPluginPostToTheWall = function () {
var options =
{
method: "feed",
name: "Shared via my cool app",
message: "This is a post shared from my app. I have earned 300xps."
};
facebookConnectPlugin.showDialog(options,
function (response) {
alert(JSON.stringify(response))
});
};
And it shares the post to the facebook, but I can't make it work with these preset values for message, title etc. It just shares the text I enter in the popup shown after calling this function. I hope someone can help with this.
The feed dialog does not accept any prefilled messsage - but prefilling is not allowed anyway, the message always must be 100% user generated.
If you want to post without a dialog, you have to authorize the user with publish_actions and use the feed API: https://developers.facebook.com/docs/graph-api/reference/v2.2/user/feed
But again, prefilling the message is not allowed. Read the platform policy for more information: https://developers.facebook.com/policy/

Resources