Now that PhoneGap is version 2.0, is there a (potentially undocumented) way to have a contact picker?
The docs make it seem like I'd have to write my own in JavaScript by requesting ALL the user's contacts, then building my own in-app contact picker.
http://docs.phonegap.com/en/2.0.0/cordova_contacts_contacts.md.html#Contacts
I've found a one-off plug-in for Android, but that's not helpful if there's no plug-in for iPhone, cause then I'd still have to write my own. I'm looking for a device agnostic method that says "let the user go pick a contact, then send them back here with that contact info"
I don't know whether you can use this solution for Android as well but for iPhone you can use the .chooseContact() method.
Example:
Choose a contact
function contactChooser(){
//The chooseContact method will open a new window with all you contacts
navigator.contacts.chooseContact(
//After picking a name you will receive the id of the chosen contact
function(id){
//In an options variable you can set some filter parameters
//In this example we will use the Id to receive the data of the chosen contact
var options = {
filter: ""+id
}
//In the fields variable we're going to set the fields we want to receive
//'*' = every data. More field values are explained
// here: http://bit.ly/T8YyuE
var fields = ['*'];
navigator.contacts.find(fields, onPickContactSuccess, onPickContactError, options);
}, null);
}
function onPickContactSuccess(contacts){
//contacts contains all data you've requested
var _name = contacts[0].name
alert('Last: '+_name.familyName+' First: '+_name.givenName);
}
Related
I am trying to push the form data to the firebase-firestore. And I also did it successfully. But, the problem is that whenever I am trying to submit the form data again and again it just updates the last data with the current data.
Actually, my requirement is that whenever the user hit the submit button. It creates a document with a random id and stores the all data into that specific id that is generated.
You are specifying the document ID in .document() so it'll overwrite the same document. If you want a document with a random ID on every click, try using add() instead as shown below:
val collectionRef = FirebaseFirestore.getInstance().collection("Maintainance")
collectionRef.add(user).addOnCompleteListener(...)
Alternatively, you can leave .document() empty to get a DocumentReference with a random ID:
val userDocument = FirebaseFirestore.getInstance().collection("Maintanance").document() // <-- don't pass an ID
In addition to #Dharmaraj answer:
CASE_1: In a case where you need to track each user's all submitted forms, probably from your explanation you may need to organize each user's form.
Therefore if you need to organize each user's form then create another sub-collection [example: document(userId).collection("USER_FORMS")] within userID document like this:
val documentRef = FirebaseFirestore.getInstance().collection("Maintainance").document(UserUtils.user?.id.toString()).collection("USER_FROMS").document();
CASE_2 : In a case where you need to make your own custom document ID:
1- make a random number or string or any other data type.
2- The random number/string variable must be local to the code block/method that will execute the form submision function.
3- use the number/string generated as the form document Id like this:
//This must be local so as user clicks submision button so as it generates new random number;
val randomFormId = "generateThenumberOrStringAndInitializeTheVariable";
Then use the random number as the form document Id like this:
val documentRef = FirebaseFirestore.getInstance().collection("Maintainance").document(UserUtils.user?.id.toString()).collection("USER_FROMS").document(randomFormId);
i have made a qr scanner in android that sends the value to google sheets using dopost() now i want to setup a trigger to automatically send mail to the user whenever a new row is inserted into the google sheets.
I have tried onEdit() and onChange() but it's not working
Did you create a web app to insert data into a Spreadsheet? Your question suggests that because you say when user information is inserted into a new row using doPost(). So to be clear doPost() and doGet() are used to support get requests and posts from a webapp. If that is what you are doing then please make it more clear.
But it sounds to me that your expecting the onEdit() to trigger a change when the webapp changes the data in the spreadsheet. Unfortunately, that's not going to happen. The documentation from Simple Triggers states onEdit(e) runs when a user changes a value in a spreadsheet. not when your script changes a value.
But really why don't you just send the email when you update the spreadsheet information with another Google Apps Script.
Question Response
Since your using doPost() why don't you just use a form and then you don't have pass everything in the query string.
function addItem(e){
var ss = SpreadsheetApp.openByUrl("url");
var sheet = ss.getSheetByName('Sheet1');
var date = new Date();
var Roomnumber = e.parameter.Roomnumber;
var email = e.parameter.email;
sheet.appendRow([date,Roomnumber,email]);
}
function sendEmails() {
var ss = SpreadsheetApp.openByUrl("url");
var sheet = ss.getSheetByName('Sheet1');
var range = sheet.getRange(sheet.getLastRow(),1,1,3);
var values = range.getValues;
var date=values[0][0];
var roomnumbeer=values[0][1];
var email=values[0][2];
//code to send mail
}
I'm a real rookie with Android and especially 'Save to Android Pay' API. I'm following the Google's Guide and Google's Sample, in order to implement my own offer class and "Save to Android" button.
According to the tutorial, for every type of offer card I'm creating, I need one Offer Class, and for every user who will save the card to his Android Pay app, a new object will be generated. So Let's say my card has the following fields:
Headline
Logo
Card ID#
and in addition, every user has 2 unique fields:
User ID#
User ID2#
I know when and how to pass the first 3 fields of data but I'm not sure where and how to pass the last 2 fields. I'm implementing the "Save to Android" button on a website (exactly like the sample) and assume I have the two data fields save as JavaScript variables on my website. Can I send the 2 unique fields to "Save to Android Pay" API Servers from my website while (or before) the user clicks the "Save to Android Pay" button?
Got an answer from 'Save to Android Pay' team:
There is a section in the Loyalty.java class that creates an object with specified parameters. The Java quickstart has hard-coded values as an example, but can be easily changed to the variables you use to keep track of user's ID numbers, etc.
You can can insert your user's unique values in this section:
// Define Wallet Instance
LoyaltyObject object = new LoyaltyObject()
.setClassId(issuerId + "." + classId).setId(issuerId + "." + (Math.random()*1000))
.setState("active").setVersion(1L).setBarcode(barcode).setInfoModuleData(infoModuleData)
.setAccountName("Jane Doe").setTextModulesData(textModulesData)
.setMessages(messages).setLinksModuleData(linksModuleData)
.setAccountId("1234567890").setLoyaltyPoints(points);
Also note that in the WobGenerateJwtServlet.java class, it creates a JWT depending on the object type. Specifically for loyalty objects here:
// Create the appropriate Object/Classes
if (type.equals("loyalty")) {
LoyaltyObject obj = Loyalty.generateLoyaltyObject(credentials.getIssuerId(),
context.getInitParameter("LoyaltyClassId"), context.getInitParameter("LoyaltyObjectId"));
obj.setFactory(new GsonFactory());
payload.addObject(obj);
I have an application where I need to return the first user found that meets certain criteria, some of that criteria is having a certain number of objects stored.
For example, let's say I want to return the first store I can find that has at-least 3 employees with atleast two children. I know, what an odd-ball example. So I would have a query something like this:
PFUser.query()?
.whereKey("objectId", notEqualTo: PFUser.currentUser()?.objectId!)
.includeKey("stores.employees.children")
// .whereCountForkey("stores.employees", greaterThan: 2)
// .whereCountForKey("stores.employees.children", greaterThan: 1)
.getFirstObject();
Notice the commented out lines, I'm trying to find a way to do soemthing like this in a single query. I'm using parse, which I believe uses MongoDB on the back end, but I don't believe you can execute custom database queries..?
This is a mobile application for both iOS and Android, although the code shown is in SWIFT I have two variations of the project. Examples in either swift, obj-C, Java, or C# will be fine.
Also more than happy with Cloud-code solutions.
There is an example in the documentation
var Team = Parse.Object.extend("Team");
var teamQuery = new Parse.Query(Team);
teamQuery.greaterThan("winPct", 0.5);
var userQuery = new Parse.Query(Parse.User);
userQuery.matchesKeyInQuery("hometown", "city", teamQuery);
userQuery.find({
success: function(results) {
// results has the list of users with a hometown team with a winning record
}
});
I am new to this stuff, so I hope my question makes sense..
Basically what I want to be able to do is GET and POST data to the Google App Engine server I am running. Then, I want to be able to retrieve that same data from other devices that are accessing the server.
So let's say a user runs my app, enters in a String: "blue", and through some API that I define in an endpoint, my app takes that String and sets a GLOBAL variable that exists on my server equal to that string. ( String color = "blue" )
Then, if another user opens my app, I want him/her to be able to see color = "blue" because it has been set by another user, and if this other user wants to change the color to color = "pink", then it will change across all devices again!
So, I know how to create an API / API method, as described in the Cloud-endpoints tutorial. Example :
public class MyEndpoint {
#ApiMethod(name = "sayHi")
public MyBean sayHi(#Named("name") String name) {
MyBean response = new MyBean();
response.setData("Hi, " + name);
return response;
}
}
But how would I go about achieving what I have described above?
You cannot set "global" variables on GAE as your instances are constantly being created and destroyed to manage user traffic.
You'll have to use a shared instance like Memcache (volatile) or datastore (persistent) to reuse values across instances