How to make dynamic apps using Phonegap?

  • 2
  • Problem
  • Updated 6 months ago
Hi there, i am a student creating an app. But having some problems, i still cudn't found that what are the plugins and how we can use i used many from list but all they are not responding. Phonegap Team please help me i just want to create an app with camera(to capture images) and Call(to a particular number) how i can use them? I am using build.phonegap.com using dreamweaver. Thanks in advance. I also attached the screen shot of my app
Photo of Saba Rais

Saba Rais

  • 724 Posts
  • 3 Reply Likes

Posted 4 years ago

  • 2
Photo of Saba Rais

Saba Rais

  • 724 Posts
  • 3 Reply Likes
FOR MY THIS PROJECT, I ONLY NEED ONE PAGE CODING FOR THIS following form:


do it Petra for me Please, I know You havn't much time, You are busy person to help others, Your this deed God can't avoid at the day of judgement, But please tell me code for this form.
please please please.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
What does "copyright reserved" mean at the bottom of that page?
Photo of Saba Rais

Saba Rais

  • 724 Posts
  • 3 Reply Likes
Not matter, Sir/ma'am, i just write it, It's not published yet, so i Will remove it, Its not matter
Photo of Saba Rais

Saba Rais

  • 724 Posts
  • 3 Reply Likes
Petra, this is updated!
Photo of Saba Rais

Saba Rais

  • 724 Posts
  • 3 Reply Likes
why u don't finish this posting/problem, once helped me. :(
By only this reason, you stopped to help me that I am a student, Actually we all are students, we are learning, we are keeping update ourself by internet.
WE are all learner, I am trying my level best to learn and present my skills, in India, in my Class I am topper, but i know actually in IT where I stand. After visit here, i know my reality. Still I am not leaving hope, I will learn I will fulfill all the weak points which I have. I am asking your help to make my app better, Petra, I dont know who are you, and how much old you are, and else. I just want that complete my, and send me source code, i will learn it, I am not telling lie, I am also not a small child, I am 22 Years Old.
Please I don't want my insult here, they have announced my name here.
:(
I am really in big trouble now PETRA,
In day or night just these things moving around in mind, In dream also I am only watching these all, May be you are thinking that How bad I am, u helped me from beginning and I cought you. Sorry Petra, But You were angle for me now, except u there's no hope.
I am a student that's truth but THIS IS NOT SCHOOL PROJECT wallahi(GOD SWEAR).
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Of course, I believe you if you say this is no school project. It's a business assignment you took on. You have a community as a client and you are the contractor/vendor of a IT solution you should deliver.

I can't build that app for you. I am not a subcontractor.
You must fulfill your contract duties or
- find a local subcontractor, or
- return the contract to the client, possibly paying a contract fine
If this is business, you must handle it businesslike.
Photo of Saba Rais

Saba Rais

  • 724 Posts
  • 3 Reply Likes
If You don't want to create/complete my app, It's your wish Petra, I was just want a code sample with Json to store data,
BY d way I can't ignore your support/help for me. I can't avoid whenever I post a question You helped me, even I asked also, which was not subject matter, still you guide me , thank you very much Petra. I will remember you in my prayer.

and please Believe on it too.

  1. It's also not my business, If it was my business, I never ask you, because i could have a team of software developers.
  2. I am creating first time a mobile app.
  3. Locally no one here who can help me, because my teachers also dont know how to create apps as I said before.
  4. May be,you are bound in some rules. I don't want you break them for me, but it's not business or passion.

    I am alone, I have no sub contractor, May be you are in a misunderstandings because You saw Copyright Reserved ? I just saw at any website and type here, I am honestly saying I am not connected to any organization. NPP is a community when they came in our college, when they assign me this task. BUT its not from our course syllabus.

    I took only this project individually. BELIEVE OR NOT
    GOODBYE PETRA
    I CAN'T PAY YOUR THANKS IN WORDS

    Therefore I will pray for you, :)

Photo of Saba Rais

Saba Rais

  • 724 Posts
  • 3 Reply Likes
Complains.php


<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
<title>Post Complain</title>
</head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<body>
<script>
$(document).ready(function() {
//////////////////////
$.getJSON("student-data.php", function(return_data){
$.each(return_data.data, function(key,value){
$("#student").append("<option value=" + value.compltypeid +">"+value.description+"</option>");
});
});
//////////////////////
////////////
$('#student').change(function(){
//var st=$('#student option:selected').text();
var st=$('#student').val();
alert(st);
});
});
</script>
<select name=student id=student>
</select>

</body>
</html>



Complaindata.php

<?Php
require "config.php"; // Database Connection

$sql="select compltypeid, description from compltype where active='y' order by description asc ";
$row=$dbo->prepare($sql);
$row->execute();
$result=$row->fetchAll(PDO::FETCH_ASSOC);

echo json_encode(array('data'=>$result));
?>




Config.php

<?Php
///////// Database Details ////
$dbhost_name = "localhost";
$database = "amroclean";
$username = "root";
$password = "";

try {
$dbo = new PDO('mysql:host=localhost;dbname='.$database, $username, $password);
} catch (PDOException $e) {
print "Error!: " . $e->getMessage();
die();
}
?>
Photo of Saba Rais

Saba Rais

  • 724 Posts
  • 3 Reply Likes
Petra, Now It's fetching description into pick list, using json.
But I have little doubt, can u please answer?




  • Should I create Complete form with json and jquery, or It's sufficient only for picklist?
  • All the php files I will save with .php extensions, but when I will call httprequest using AJAX XHR calls, then In which file extension I will save AJAX XHR calls file? in .js?



  • Thanks in Advance
    Photo of Petra V.

    Petra V., Champion

    • 7794 Posts
    • 1391 Reply Likes
    1. Just the dynamic data (in this case the picklist data). All static parts are html only.

    2. In theory any extension will do (or even none at all). It is common to use .js though.
    Photo of Saba Rais

    Saba Rais

    • 724 Posts
    • 3 Reply Likes
    The field 'Other' will be same like name, location and emaiil? to post data?
    -When user will fill other description field, data will insert into description list, and then It can be added into picklist dynamically?, is that?
    Photo of Petra V.

    Petra V., Champion

    • 7794 Posts
    • 1391 Reply Likes
    No, the description is posted and then processed in back office. You don't want users to add complaintTypes. That should be done by the application admin, only.
    Photo of Saba Rais

    Saba Rais

    • 724 Posts
    • 3 Reply Likes
    you mean that, we should not give this option to users, to add new complain type? What,if they didn't found their complain regarding in picklist?
    -And admin, how he can recognize people's various complaints to update picklist?
    THEY WILL USERS, right? who can send us, their various complaints type?


    This can be not good, if we will add new complain by users, because our databases can be overloaded by unwanted text. But what is the solution now?
    WHat we can do for Other complaints, which are not in the pick list?



    Or I Should remove this option from App?
    Thank you
    Photo of Petra V.

    Petra V., Champion

    • 7794 Posts
    • 1391 Reply Likes
    *sigh*
    Back to the process, then.

    1. What happens if a user files a complaint? Who receives it? What happens next? According to what workflow are statuses updated? Does the complaining user have any further task in the process (like accepting the final solution or reopening a closed complaint)?

    2. Who is the owner of the app? Who is responsible for application management? In which organization is the admin for the app's key data situated?
    Photo of Saba Rais

    Saba Rais

    • 724 Posts
    • 3 Reply Likes
    Good Morning Respected Petra,
    I have took this project to earn and learn something new, (Really I learned too much by you), I am an Independent girl, I bear all my expenses my self, I never ask to my parents, Therefore doing study and job together.
    By d way,
    I will submit this App to NPP Community. Now It's NPP's DB Manager's duty that:

    1. When a user files a complain, they will update their databases, to see the whole complaints booked in an hour,day or in a week, the next step will be assign task to their employees(sweepers or electricians) to solve the problems, The DB Manager can also Query to know that how much complaints were booked by same user or how many people booked the same complaints.
      And When complain will be solve they can update their status solved or unsolved.


    2. Of course they will be owner of App (NPP Community). They will be responsible for application manager (Both front and Backend).
    Photo of Petra V.

    Petra V., Champion

    • 7794 Posts
    • 1391 Reply Likes
    Good.
    So:
    a. the user can either pick a complaint type from the pick list or he can write a short description as complaint type. As far as I'm concerned, he can also not supply a complaint type at all and just describe the problem

    b. in the back end application, the DB Manager should have the following functionality:
    - create, update , activate and deactivate ComplaintTypes
    - change the complaintType of a Complaint

    Be aware that these are just my suggestions. In the real IT World, the developer (or an assigned information analyst) would go to the DB Manager and ask this person for his requirements (both prior to data analysis and during development and test)
    So, you should not ask me what they require, but the DB Manager. Do you have his phone number?
    Photo of Saba Rais

    Saba Rais

    • 724 Posts
    • 3 Reply Likes
    Respected Petra,
    Thank You, your two points(a&b), I got very well.
    -Yes, I have their phone number, Although they will hire a qualified DB Manager, but still I will connected to them.



    Your Suggestions are my commands, Petra.
    Actually after an IT graduated student, i was still blind to the IT, It's seems like I am IT Illiterate, but after meeting you, I am too much affected, Now I start to improve my IT skills, I will be highly thankful to you, because It's you who helped my wihout any greed and track me on right IT path.

    And I also know that your expensive/valuable suggestions I am getting here for free, It's a huge pleasure for me really :)
    Thank You
    Photo of Saba Rais

    Saba Rais

    • 724 Posts
    • 3 Reply Likes
    Dear Petra,
    These are the tables, you created for me with their relationship.

    I have made some changes, I added two new attributes to the table complaint.
    e.g. Status, and Date/time. With same relationship.
    Now i have confusion , that when a user will submit the form, with all fields, (Personname, locationtxt, lat, lang, etc.), It will store in Database, but when a user will choose complain type, where it will store? in which field? or what process will be run, please help me Petra.
    Photo of Petra V.

    Petra V., Champion

    • 7794 Posts
    • 1391 Reply Likes
    This will be an important lesson for you.


    In a relational database, you never store again what you already have


    So, if a user files a Complaint about the type "Street Damages", you store the Complaint (because it is a new Complaint, which you don't have yet)....but you don't store the ComplaintType "Street Damages" (because you already have it; let's say it has ComplTypeID: 13)


    In a relational database, you assign relationships between 'things' you already have


    Such relationships are stored using foreign keys. The value of the foreign key will be the primary key of the related entity.

    See? That's the last field of Complaint.

    The new Complaint will be related to ComplType with key=13


    If this is new to you, you should stop your project. You first need to work your way through the most basic classes of relational databases.
    (Edited)
    Photo of Saba Rais

    Saba Rais

    • 724 Posts
    • 3 Reply Likes
    Yes Petra, I know all what you said, because i have created dynamic pick list first time, so I had a little confusion. About ER Model, relationship b/w tables, through primary and foreign keys, i know very well, even i revised RDBMS yesterday,


    You mean that when a user will files a complain type which is already in PickList, like if user will choose complaintype: Road & Foothpath, It's primary key(e.g. foreign key in Complaint table) will automatically feed in Compltypeid attribute of Complaint table?
    Thanks
    Photo of Saba Rais

    Saba Rais

    • 724 Posts
    • 3 Reply Likes
    Dear Petra, I was just looking your profile, I am single one who have lots of replies :p, from where you keep patience like this? to answer of my all questions?
    Are you really an Internet bot? :D
    Photo of Saba Rais

    Saba Rais

    • 724 Posts
    • 3 Reply Likes
    Dear Petra,
    Can you please help me, the form is near about to complete, but I am stuck off at one place, which is Find location on google map, for image i used <input name="fileToUpload" type="file" id="fileToUpload">
    But for lat and lang coordinates, which type of form-fields i can use?
    or how i can choose lat and lang coordinates for a particular location? and how i can store in a variable to send them in a database(mysql)?
    I saw at google, they all are for current location...
    Need for hint/suggestions
    Thank You very much.
    by your lessons, i am really learning much, and also storing them into a personal notebook.
    Photo of Saba Rais

    Saba Rais

    • 724 Posts
    • 3 Reply Likes
    Petraaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
    Photo of Petra V.

    Petra V., Champion

    • 7794 Posts
    • 1391 Reply Likes
    To allow users to take a picture or select an image, use cordova-plugin-camera.
    To send it to a server, use cordova-plugin-file-transfer.
    Don't use a html file-input.

    For the location, offer 'current location' using cordova-plugin-geolocation or a textual location description. Anything more would be way over your head.
    Photo of Saba Rais

    Saba Rais

    • 724 Posts
    • 3 Reply Likes
    For Camera plugin, i used jesse's demo app e.g.
    https://github.com/jessemonroy650/Pho...
    But it's capturing and using device camera to take picture but can't send it to server.

    or

    Or i can only show to upload image?NOT USE DEVICE'S CAMERA?

    and I used already geo location plugin you told me before, but i am unable to find source code for form.
    Photo of Saba Rais

    Saba Rais

    • 724 Posts
    • 3 Reply Likes
    See My Config.xml file.

    <?xml version="1.0" encoding="UTF-8" ?>
    <widget xmlns = "http://www.w3.org/ns/widgets"
    xmlns:gap = "http://phonegap.com/ns/1.0"
    id = "com.phonegap.example"
    versionCode = "10"
    version = "1.0.0" >

    <!-- versionCode is optional and Android only -->

    <name>AmroClean</name>

    <description>
    This app let you Clean your City within no time, Keep your City Clean and Green, Regards: Nagar Palika Parishad
    </description>

    <author href="https://build.phonegap.com" email="support@phonegap.com">
    Saba Rais
    </author>
    <icon src="images/icon.png"/>
    <content src="index.html"/>

    <plugin name="cordova-plugin-whitelist" />
    <plugin name="cordova-plugin-device" source="npm" spec="1.0.1" />
    <plugin name="call-number" source="npm" spec="0.0.2" />
    <access origin="http://phonegap.com" subdomains="true" />
    <gap:platform name="ios" />
    <gap:platform name="android" />
    <gap:platform name="winphone" />
    <preference name="permissions" value="none"/>
    <gap:plugin name="org.apache.cordova.device" version="0.3.0" source="npm"/>
    <gap:plugin name="org.apache.cordova.camera" version="0.3.6" source="npm"/>
    <gap:plugin name="cordova-plugin-socialsharing" source="npm" version="4.3.81" />
    <plugin name="cordova-plugin-geolocation"/>
    <access origin="tel:*" launch-external="yes" />
    </widget>


    All plugins are there, except file-transfer, I will add it later.
    Photo of Petra V.

    Petra V., Champion

    • 7794 Posts
    • 1391 Reply Likes
    1. The Camera plugin doesn't send anything. You need the file-transfer plugin for that

    2. Why do you want input fields for lat/lon? Your users don't have to type them in, do they?
    When the form is displayed, include a small Google map picture with a pin at the current location. Add a check box, to be checked if the users wants to post that location.
    Of course, you only do that after detecting that location lat and lon are being passed on that device at all.
    Photo of Saba Rais

    Saba Rais

    • 724 Posts
    • 3 Reply Likes

    1. In the entire form, all fields are related to text, but image is a file. I will not send image to server separately right?, It will post along with all fields right?, I was thinking like that, by ulpoad button user can hold image into an field, and it can post with all text fields to database, Like following picture, Is that possible?

    2. Of course I don't want that user input lat&lon values, they can't even exact ever.
      I want when user choose a location from a google map, and pin at the any particular location, automatically the lat&lon coordinates fetch and when a user submit the entire form, they store in database with their name,email,and image.

    Photo of Saba Rais

    Saba Rais

    • 724 Posts
    • 3 Reply Likes
    Have a Good Day R/s Petra
    Q1.I used now, camera API to capture an image, but as we discussed that user can't capture picture at same/current time sometime, I want to give another option also OR "Choose from Gallery". How can i do that?Is there any additional plugin for that?
    Q2.The "Add Image button is launching device's camera to capture image and after click its showing like following, what is the next step to send picture to the server?
    Thanks in advance.
    Photo of Petra V.

    Petra V., Champion

    • 7794 Posts
    • 1391 Reply Likes
    1. That's also the Camera plugin (see: sourceType parameter). Read and follow the full docs and not just the first paragraph.

    2. The next steps are:
    - validate form input and show error messages if needed
    - invoke the file transfer plugin to send the image and further post data OR use ajax/xhr to post everything (e.g. image ase base64 data)
    - wait for server response and either show error message or confirmation
    - have a strategy in place for the offline case.