B4A Library Parse Library – Push Notifications and Cloud Storage

ArminKH

Well-Known Member
is there any way to remove Start At Boot permision from this library?
 

Marvinb

New Member
Licensed User
Longtime User
I am trying to run a ParseDemo but it shows an error while trying to connect with my phone through wifi. this is the error 'src\b4a\example\parse\main.java:355: error: package anywheresoftware.b4a.objects.ParseObjectWrapper does not exist
public static anywheresoftware.b4a.objects.ParseObjectWrapper.ParseWrapper _parse = null;' have anyone came across this?
 

jamesnz

Active Member
Licensed User
Longtime User
Parse can do some very clever user authentication through Facebook Google etc but we need the parse user functionality. If anyone is interested in adding this is be keen to help pay for the time. If so let me know and I'll post a job in the jobs section.
 

stu14t

Active Member
Licensed User
Longtime User

I've been messing about with inline Java code. Now the following allows you to login (if you already have a user created inside Parse) but I'm having issues with the callback from the login sub in the Parse Jar.

This code logs you in and if you have an account returns the objectID of that user account. You could use that to validate the login process by checking an ObjectID is returned but If someone could help with the callback this would not be needed.

My code is not elegant i'm afraid but it works. You will need to substitute your own Master / Application keys where you see XXXXXXXXX

B4X:
#AdditionalJar: ParseNative

#If JAVA
import com.parse.ParseUser;
public String getCurrentUserId() {

    String objectId = "";
 
    ParseUser user = ParseUser.getCurrentUser();
    if(user != null) {
        objectId = user.getObjectId();
        return objectId;
    } else {
        return "";
    }
 
}
#End If

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim Parseint As Parse
    Dim UserName As String
    Dim Password As String
    Dim Result As Object
 
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private Login As Button
    Private TxtUsername As EditText
    Private TxtPassword As EditText
    Private NativeMe As JavaObject
    Private BtnLogout As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
 
 
    Parseint.Initialize("XXXXXXXXXXXXXXXXXXXXX","XXXXXXXXXXXXXXXXXXXXX")
 
    If FirstTime Then 
     NativeMe.InitializeContext
 
    End If
 
    Activity.LoadLayout("Main")
 
 

End Sub

Sub ParseLogin As JavaObject
    Dim PL As JavaObject
    Dim jo As JavaObject
  
    'Use the JavaObject to access the ParseUser & LoginCallback
    PL.InitializeStatic("com.parse.ParseUser")
    jo.InitializeStatic("com.parse.LoginCallBack")
 
    'Run the Login Static method
    Dim callback As Object = jo.CreateEventFromUI("LoginCallBack", "Callback",Null)
    Result = PL.RunMethod("logInInBackground" , Array As Object (UserName,Password,callback))
 
    'Run the Inline Java to get the ObjectId of the CurrentUser 
    Dim s As String = NativeMe.RunMethod("getCurrentUserId", Null) 
 
    Log(Result)
    Log(s)
 
 
End Sub
Sub Callback_Event (MethodName As String, Args() As Object) As Object
   Log(MethodName & "   "  & Args)
End Sub
Sub Activity_Resume
 

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub



Sub Login_Click

    UserName = TxtUsername.Text
    Password = TxtPassword.Text
 
    ParseLogin 
 
End Sub
Sub BtnLogout_Click

    Dim logout As JavaObject
 
    logout.InitializeStatic("com.parse.ParseUser")
 
    logout.RunMethod("logOut",Null)
 
    Dim s As String = NativeMe.RunMethod("getCurrentUserId", Null) 
 
    Log(s)
 
End Sub
 

Kwame Twum

Active Member
Licensed User
Longtime User
Hello everyone, I keep getting "Unfortunately, ParseDemo has stopped" as soon as the app starts.
Nothing gets printed to the logs... both filtered and unfiltered
What could be wrong please?
 

hookshy

Well-Known Member
Licensed User
Longtime User
Hello everyone, I keep getting "Unfortunately, ParseDemo has stopped" as soon as the app starts.
Nothing gets printed to the logs... both filtered and unfiltered
What could be wrong please?
You can post code to track your errors ... For example when you read a key that does not have correct formatting the app will crash without any explanations
 

Kwame Twum

Active Member
Licensed User
Longtime User
You can post code to track your errors
Thanks @hookshy
I downloaded the sample from here... created my res.xml file (as specified with my keys), made it readonly.... no need to modify manifest as it's already done in the sample. Then I run the app and got that message on the phone...
B4A version: 5.20
TargetSdkVersion: 21
 

hookshy

Well-Known Member
Licensed User
Longtime User
I wanted to find an answer but searching the parse forum i found out that query is done
for max 1000 items
but note that query.limit=-1 as documented in b4a library does not work and gets only 100 itmes
in advance you must set up query.limit=1000

B4X:
 Dim query As ParseQuery
  query.Initialize("feed")
  query.Limit=-1 ,'????? this condition retrieves only 100 elements
  query.Find("get_feed", 1)
 
Last edited:

Serdar K.

Member
Licensed User
Longtime User
If someone wants to use the latest version of the library (1.4), here are Parse.com ' s older SDK files.
https://github.com/yongjhih/parse-android-sdk

I tried and managed to make the demo code work with agraham's library (i only removed the notification and push part, but i don't think it will change the result.)
It's working very well with Parse-1.7.0.jar as ParseNative.jar

Thanks everyone contributing this platform beginning with Erel.
Also i would like to send my special thanks to agraham also.
 

hookshy

Well-Known Member
Licensed User
Longtime User
I have problems with queryby Id ... It works only on main activity
If I run the code with another activity I get this error Sub test_done_get signature does not mach expected signature

Any ideas what shall I change ?
Thank you

B4X:
Sub feed_click

Dim query As ParseQuery
query.Initialize("feed")
query.GetById("test",docid,2)
ToastMessageShow("get_feed",True)
End Sub

Sub test_DoneGet(Success As Boolean, PO As ParseObject, TaskId As Int)
' java.lang.Exception Sub test_done_get signature does not mach expected signature

end sub
 

Serdar K.

Member
Licensed User
Longtime User

I could suggest you to delete application data and cache on the device, then uninstall the application from the device and reinstall the application. After trying many different libraries this helped me.
 

hookshy

Well-Known Member
Licensed User
Longtime User
I could suggest you to delete application data and cache on the device, then uninstall the application from the device and reinstall the application. After trying many different libraries this helped me.
I tried but it seems it might be something else going on .... problem is with the my activity but I did not found yet
 

pesquera

Active Member
Licensed User
Longtime User
Hi, I have an app using this library.. working wonderful! I should migrate it with time.. any advice or idea about replacing this service will be appreciated.. thanks!
 

Serdar K.

Member
Licensed User
Longtime User
One possible alternative is to get a VPS and use B4J to implement the back end.
Start with jRDC and the push server.

Prices for VPS can be as low as 10$ per month.

I just made it work and they shut it down.

Anyway, we have to find a solution.They announced a couple days ago their planned shutdown after 1 year. They suggest to migrate to other cloud services. I myself think of moving to Google Cloud SQL or VPS hosted MySQL as a long term solution.

Alternatively, they made "most of the" Parse server sources available open, but the matter was the service and cloud support.
One single server is not reliable as a cloud platform with several backup servers on a network. It costs money to have that servers on our own.

It's a shame that they choose to shut Parse down.
 
Last edited:

Gentry

Member
Licensed User
Longtime User
Any chance that the B4A Parse Library can be adjusted to support moving the URLS so folks can point their B4A apps toward a private migrated Parse environment? If not, any chance the B4A library source code can be released to allow us to make that modification?

Thanks
 

Gentry

Member
Licensed User
Longtime User
Erel, thank you. Looks like the change to the wrapper should be like this:

B4X:
    /**
     *Add to Manifest Editor
     *SetApplicationAttribute(android:name,"anywheresoftware.b4a.objects.ParseObjectWrapper$ParseApplication")
     *
     *Add to file res/xml/res.xml replacing with the ppropriate keys and make read-only
     *<!--?xml version="1.0" encoding="utf-8"?-->
     *<data>
     *    <data1 value="YourAppId" />
     *    <data2 value="YourClientKey" />
     *     <data3 value="ParseServerURL" />
     *</data>
     *
     */
    public static class ParseApplication extends Application
    {

        @Override
        public void onCreate()
        {
            String appID = "";
            String clientKey = "";
            String serverURI = "";
          
            super.onCreate();

            Resources res = this.getResources();
            int id = res.getIdentifier("res", "xml", this.getPackageName());
            Log.v("B4A","ParseApplication.onCreate xml Id = " + id);
            XmlResourceParser xml = res.getXml(id);
            int eventType;
            try
            {
                eventType = xml.getEventType();
                while (eventType != XmlPullParser.END_DOCUMENT)
                {
                    if (eventType == XmlPullParser.START_TAG)
                    {
                        Log.v("B4A",xml.getName() + " " + xml.getAttributeValue(null, "value"));
                        if (xml.getName().equals("data1"))
                            appID = xml.getAttributeValue(null, "value");
                        if (xml.getName().equals("data2"))
                            clientKey = xml.getAttributeValue(null, "value");
                        if (xml.getName().equals("data3"))
                            serverURI = xml.getAttributeValue(null, "value");
                    }
                    eventType = xml.next();
                }
            } catch (Exception e)
            {
                Log.v("B4A", "ParseApplication exception: " + e.getMessage());
            }
            xml.close();
            Parse.initialize(this, appID, clientKey, serverURI);
        }
    }
}

Now.... I'll figure out how to compile the modified library and test it out...
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…