Giter VIP home page Giter VIP logo

android-sdk's Introduction

BaasBox

BaasBox is an Open Source project that aims to provide a backend for mobile and web apps.

Further information can be found at www.baasbox.com.

API and SDKs documentation is here.

Community forum is here.

Build BaasBox

Prerequisites

To build and run BaasBox you need a JDK (not JRE!) (version 8) (download here) and the Play! Framework 2.2.4 (download here).

Important: You must have Play! Framework 2.2.4 installed! BaasBox will not build with other versions.

Once you have installed the above software following, you will be able to build BaasBox.

Download the source code from GitHub

Build

Go to your local BaasBox source code directory and type:

play clean-all baas

Play! will build BaasBox and will create a .zip file in the ./dist directory.

The .zip file contains everything you need to run BaasBox. Unzip it, set the execution permission on the start file and run it.

Windows users can use the start.bat file.

BaasBox will create a new database in the ./db directory, and it will start.

To test it visit http://localhost:9000 and you will see the BaasBox start page.

To access the Admin Console Panel, go to http://localhost:9000/console

Default credentials are:

  • username: admin
  • password: admin
  • application code: 1234567890

Bitdeli Badge

android-sdk's People

Contributors

bitdeli-chef avatar davidecaroselli avatar eliantor avatar giastfader avatar spomytkin avatar zebehringer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-sdk's Issues

AccountManager supportable Login Authentication

Android SDK needs AccountManager supportable Login Authentication

The current api gives following json results after login with X-BB-SESSION as token !!

{
"result": "ok",
"data": {
"user": {
"name": "cesare",
"status": "ACTIVE",
"roles": [
{
"name": "registered"
}
]
},
"signUpDate": "2014-01-23 23:00:18",
"X-BB-SESSION": "41b7ce0f-be44-4737-b346-907483155ad8"
},
"http_code": 200
}

1>There is no option in baasbox android sdk api for adding the auth token (X-BB-SESSION ) to BaasDocument (to retrive REST API) such that it can be used for write-your-own-android-authenticator ( http://blog.udinic.com/2013/04/24/write-your-own-android-authenticator/) with Android AccountManager!

2>AccountManager api we can't do Multi user login !

  1. We can't use sync adapter with AccountManager !

ProtocolException if server is restarted and BaasUser is logged in

Seems to be the same issue as #32 but in a different scenario.

Steps to reproduce:

Login with a BaasBox User.
Restart BaasBox server.
Go to somewhere in the app where BaasBox server is called and it crashes with ProtocolException.

After crashing the app can be restarted and it works fine.

If Social Login is used then it doesn't crash as in this case the session token expires with restart and BaasInvalidSessionException is thrown, which can be handled correctly.

5.0.1 Lollipop.

java.lang.Error: Got a protocol exception while setting http method
at com.baasbox.android.HttpUrlConnectionClient.setupConnectionForRequest(HttpUrlConnectionClient.java:244)
at com.baasbox.android.HttpUrlConnectionClient.execute(HttpUrlConnectionClient.java:158)
at com.baasbox.android.NetworkTask.asyncCall(NetworkTask.java:151)
at com.baasbox.android.NetworkTask.parseResponse(NetworkTask.java:74)
at com.baasbox.android.NetworkTask.asyncCall(NetworkTask.java:152)
at com.baasbox.android.impl.Task.execute(Task.java:189)
at com.baasbox.android.impl.Dispatcher$Worker.run(Dispatcher.java:170)
Caused by: java.net.ProtocolException: content-length promised 17 bytes, but received 0
at com.android.okhttp.internal.http.RetryableSink.close(RetryableSink.java:50)
at com.android.okio.RealBufferedSink.close(RealBufferedSink.java:174)
at com.android.okio.RealBufferedSink$1.close(RealBufferedSink.java:142)
at com.baasbox.android.HttpUrlConnectionClient.copyStream(HttpUrlConnectionClient.java:266)
at com.baasbox.android.HttpUrlConnectionClient.addBody(HttpUrlConnectionClient.java:252)
at com.baasbox.android.HttpUrlConnectionClient.setupConnectionForRequest(HttpUrlConnectionClient.java:228)
at com.baasbox.android.HttpUrlConnectionClient.execute(HttpUrlConnectionClient.java:158)
at com.baasbox.android.NetworkTask.asyncCall(NetworkTask.java:151)
at com.baasbox.android.NetworkTask.parseResponse(NetworkTask.java:74)
at com.baasbox.android.NetworkTask.asyncCall(NetworkTask.java:152)
at com.baasbox.android.impl.Task.execute(Task.java:189)
at com.baasbox.android.impl.Dispatcher$Worker.run(Dispatcher.java:170)

Method enablePush() not in SDK Version 0.8.0

While working with the Version 0.8.0 I wanted to register a device to receive push notifications and used the code from the Docs:

BaasBox box=BaasBox.getDefault();
box.enablePush("registrationIdByGoogle",
     new BaasHandler<Void>() {
       @Override
       public void handle(BaasResult<Void> res){
         if(res.isSuccess()){
           // registrationid saved on the server
         }
       }
     });

As it turns out the Method enablePush() is not part of the SDK any longer. Switching back to 0.7.4 and it is available.

Logger not disable

I am using Android SDK 0.9.2.

The Logger is not disable for release version so the IP and AppCode are visible in the log cat:
I/BAASBOX: requested {url ->http://xxx.xxx.xxx.xxx:9000/document/XXX?where=current+%3D+true&orderBy=creation_date+DESC&page=0&recordsPerPage=20 method: GET, headers ->{User-Agent:BaasBox AndroidSDK/0.9.2X-BAASBOX-APPCODE:xxxxxxxxX-BB-SESSION:xxxxxx-xxxxx-xxxxxx-xxxxxxx}}

This is not very secure!

On solution may be to let access to the ENABLED field :

public static final boolean ENABLED = true;

Failure of BaasUser::signup (baasbox-android-0.8.4.jar)

I am trying out the DearDiary-Android-Master example on the Android Studio with baasbox-android-0.8.4.jar. I am seeing the signup fail despite the user name and password available. The baasbox was successfuly setup and running in the background on localhost:9000. I am on Windows 7 64bit.

BaasUser.class shows

public RequestToken signup(int flags, BaasHandler handler) {
BaasBox box = BaasBox.getDefaultChecked();
if(this.password == null) { <<<<<<<<<<Issue in comparison
throw new IllegalStateException("password cannot be null");
} else {
BaasUser.SignupRequest req = new BaasUser.SignupRequest(box, this, flags, handler);
return box.submitAsync(req);
}
}

The Android Studio debugger shows that this (BaasUser) has been setup with
with a non null password (this.password) but the comparision in the BaasUser.signup() pointed
above still shows that the password to be null and I see the the IllegalStateException thrown (verified on the emulator.) as a result.

I am unable to register a user as a result. What needs to be done?

Regards
Kaustav

BaasFile.streamImage with different sizeId values returns cached data

I want to download a thumbnail of an image file so I specify sideId = 0 to get the smallest. When the cache is empty that downloads the correct file. If I later specify any other value for sizeId, then the cached data is returned, which is the wrong size.

A possible fix would be to add another method to AsyncStream called cacheKey(), by default returning streamId(), and override that in BaasFile.FileStream to return the resize or sizeId params concatenated to the streamId.

How to trust a self-signed certificate?

I'd like to connect from my Android app to an SSL server using a self-signed certificate. How do I go about doing this? If I follow the documented code, I get this exception:

08-07 11:12:15.496: E/AndroidRuntime(4540): Caused by: com.baasbox.android.BaasIOException: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
08-07 11:12:15.496: E/AndroidRuntime(4540):     at com.baasbox.android.HttpUrlConnectionClient.execute(HttpUrlConnectionClient.java:181)
08-07 11:12:15.496: E/AndroidRuntime(4540):     at com.baasbox.android.NetworkTask.asyncCall(NetworkTask.java:151)
08-07 11:12:15.496: E/AndroidRuntime(4540):     at com.baasbox.android.impl.Task.execute(Task.java:189)
08-07 11:12:15.496: E/AndroidRuntime(4540):     at com.baasbox.android.impl.Dispatcher$Worker.run(Dispatcher.java:170)
08-07 11:12:15.496: E/AndroidRuntime(4540): Caused by: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
08-07 11:12:15.496: E/AndroidRuntime(4540):     at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:409)
08-07 11:12:15.496: E/AndroidRuntime(4540):     at com.android.okhttp.Connection.upgradeToTls(Connection.java:146)
08-07 11:12:15.496: E/AndroidRuntime(4540):     at com.android.okhttp.Connection.connect(Connection.java:107)
08-07 11:12:15.496: E/AndroidRuntime(4540):     at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:294)
08-07 11:12:15.496: E/AndroidRuntime(4540):     at com.android.okhttp.internal.http.HttpEngine.sendSocketRequest(HttpEngine.java:255)
08-07 11:12:15.496: E/AndroidRuntime(4540):     at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:206)
08-07 11:12:15.496: E/AndroidRuntime(4540):     at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:345)
08-07 11:12:15.496: E/AndroidRuntime(4540):     at com.android.okhttp.internal.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:89)
08-07 11:12:15.496: E/AndroidRuntime(4540):     at com.android.okhttp.internal.http.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:161)
08-07 11:12:15.496: E/AndroidRuntime(4540):     at com.baasbox.android.HttpUrlConnectionClient.execute(HttpUrlConnectionClient.java:157)
08-07 11:12:15.496: E/AndroidRuntime(4540):     ... 3 more
08-07 11:12:15.496: E/AndroidRuntime(4540): Caused by: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
08-07 11:12:15.496: E/AndroidRuntime(4540):     at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:282)
08-07 11:12:15.496: E/AndroidRuntime(4540):     at com.android.org.conscrypt.TrustManagerImpl.checkServerTrusted(TrustManagerImpl.java:202)
08-07 11:12:15.496: E/AndroidRuntime(4540):     at com.android.org.conscrypt.OpenSSLSocketImpl.verifyCertificateChain(OpenSSLSocketImpl.java:611)
08-07 11:12:15.496: E/AndroidRuntime(4540):     at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
08-07 11:12:15.496: E/AndroidRuntime(4540):     at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:405)
08-07 11:12:15.496: E/AndroidRuntime(4540):     ... 12 more
08-07 11:12:15.496: E/AndroidRuntime(4540): Caused by: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
08-07 11:12:15.496: E/AndroidRuntime(4540):     ... 17 more

Exception while read the JsonObject in Android Bundle

Im getting the following exception while reading the JsonObject after I insert it on new Activity Bundle:

android.os.BadParcelableException: ClassNotFoundException when unmarshalling: com.baasbox.android.json.JsonArray

The code for put the bundle:

Intent locationDetailsActivity = new Intent(getActivity().getApplicationContext(),LocationDetailsActivity.class);

Bundle bundle = new Bundle();
bundle.putParcelable(SELECTED_LOCATION, locationObject);

locationDetailsActivity.putExtras(bundle);

The code for retrieve the values:

JsonObject location = getIntent().getExtras().getParcelable(Constants.SELECTED_LOCATION);

if (location != null) {
    getActionBar().setTitle(location.getString(BaasBoxConstants.LOCATION_NAME_FIELD));
}

Example db

Where i may find example snapshot db for aloa example?
Default ip (192.168.56.1) - not working, and on clear db - too many Exceptions on every step.

com.baasbox.android.BaasIOException: java.net.SocketTimeoutException

0.9.1 Server with 0.9.2 SDK
How should I handle SocketTimeoutException?

If I call a plugin endpoint

try {
BaasBox box = BaasBox.getDefault();
            box.rest(HttpRequest.POST,
                    "plugin/my.plugin",
                    new JsonObject().put("", ""),
                    true,
                    new BaasHandler<JsonObject>() {
                        @Override
                        public void handle(BaasResult<JsonObject> res) {

                        }
                    });
        }  catch (Exception ex) {
ex.printStackTrace(); }

then I can catch SocketTimeoutException and handle it, but if I use some of the native calls:

try {
BaasDocument.fetchAll(“mycollection”,
    new BaasHandler<List<BaasDocument>>() {
    @Override
        public void handle(BaasResult<List<BaasDocument>> res) {

                        }
                    });
        }  catch (Exception ex) {
ex.printStackTrace(); }

then it crashes with SocketTimeoutException

APIDomain with new domain name in Android 4.x.x

Some domain names can contain something like '.abcdef" (and more...) (sample : ws.mobile.mycompany instead of ws.mobile.mycompany.com)

But in Android 4.x.x, the setApiDomain causes a freeze with such domain name.

public Builder setApiDomain(String domain){
     if (domain==null) mApiDomain = "10.0.2.2";
     if(Patterns.IP_ADDRESS.matcher(domain).matches()||
         Patterns.DOMAIN_NAME.matcher(domain).matches()){
         mApiDomain = domain;
     } else {
         throw new RuntimeException("Invalid host name: "+domain+". Hint: don't specify protocol (eg. http) or path");
    }
    return this;
}

The issue is Patterns.DOMAIN_NAME.matcher(domain).matches() : the Patterns.DOMAIN_NAME is more limited in Android 4.x.x
Here are the source code from Android:

I tried to use a new method to force the API Domain without check, it works fine:

public Builder setApiDomainWithoutCheck(String domain){
    mApiDomain = domain;
    return this;
}

BaasUser

Hi, I am using BaasBox Android sdk to set up a user with username, password, name and email fields. I did not find any method to create user with visibleByTheUser attribute etc. I see that I can read this data using getScope(scope) method though. Am I missing something?

I can create user with rest api but then it defeats the sdk's purpose
curl http://localhost:9000/user -X POST

  • -d '{"username": "blah","password": "password","visibleByTheUser": {"email": "[email protected]"} ,"visibleByAnonymousUsers" :{"name": "julius caesar"}}'
  • -H Content-type:application/json
  • -H X-BAASBOX-APPCODE:1234567890

regards,
Anil

How to fetch other user profile anonymously

Hi,
I've tried to use the BaasUser.fetch() method but it gives this message:
{"result":"error","message":"Missing both Session Token and Authorization info","resource":"/user/****","method":"GET","request_header":{"X-BAASBOX-APPCODE":["1234567890"],"Connection":["Keep-Alive"],"Accept-Encoding":["gzip"],"User-Agent":["BaasBox AndroidSDK/0.8.4"],"Host":["www.XXXXX.com:9000"]},"API_version":"0.9.1-20150112-nightly","http_code":401}

So it's how it's possible to get the visibleByAnonymousUsers property of BaasUser??

Thanks in advance

User id is not retrievable from BaasUser Object

Once I login with

BaasUser user = BaasUser.withUsername("{{ USERNAME }}").setPassword("{{ PASSWORD }}");
user.loginSync();

There is no such method like user.getId()

I can get userId by doing raw request to the login and signup endpoint. But through api there is no way.

I need to link user with another user as my app contains much complex relationship among users.

Bitdeli Badge broken

Bitdeli Badge is not working in README file, so I would suggest to remove it.

BaasQuery: field inside an array

Hello guys,

I have problem with BaasQuery. I need to fillter by value of the field inside an array, for example, field "userN" inside "receivers".

Example document:
{
"creator": "998698633",
"name": "message",
"receivers": [
{
"userN": "34535346343",
"accepted": 1
}
]
}

Filter filter = BaasQuery.builder().pagination(0,20)
.orderBy("field desc")
.where("receivers[].userN = ?")
.whereParams("34535346343")
.filter();

Using this filter I don't receive any documents... Am I doing something wrong or is it a bug?

getting file stream throws NullPointerException [Android]

Hello,

I've a problem similar to this closed issue
When trying to retrieve a stream from a file, Baasbox throws the following error:

java.lang.RuntimeException: java.lang.NullPointerException
        at com.baasbox.android.ExceptionHandler$1.onError(ExceptionHandler.java:33)
        at com.baasbox.android.impl.Dispatcher$Worker.run(Dispatcher.java:174)
Caused by: java.lang.NullPointerException
        at com.baasbox.android.StreamBody.finishStream(StreamBody.java:40)
        at com.baasbox.android.AsyncStream.onOk(AsyncStream.java:115)
        at com.baasbox.android.NetworkTask.parseResponse(NetworkTask.java:60)
        at com.baasbox.android.NetworkTask.asyncCall(NetworkTask.java:152)
        at com.baasbox.android.impl.Task.execute(Task.java:189)
        at com.baasbox.android.impl.Dispatcher$Worker.run(Dispatcher.java:170)

To retrieve the file I use the same code as the documentation

files.get(i).stream(new BaasHandler<BaasFile>() {
    @Override
    public void handle(BaasResult<BaasFile> res) {
        if (res.isSuccess()) {
            byte[] data = res.value().getData();

           //do things with data

            Log.d("LOG", "File received");
        } else {
            Log.e("LOG", "Error while streaming", res.error());
        }
    }
});

BaasQuery doesn't handle Where Params correctly

The whereParams function in BaasQuery.java has:

public Builder whereParams(String... params){
if(params!=null&&params.length==0){
this.params = new ArrayList();
Collections.addAll(this.params, params);
}
return this;
}

It looks like the second line should read params.length != 0 instead of params.length == 0, as the current implementation does not work when using where parameters.

NPE while getting file content

I'm trying to get a file in BAASBOX version 0.7.4 but i´m getting NPE:

05-13 19:49:05.408: E/AndroidRuntime(19731): FATAL EXCEPTION: Thread-5212
05-13 19:49:05.408: E/AndroidRuntime(19731): java.lang.RuntimeException: java.lang.NullPointerException
05-13 19:49:05.408: E/AndroidRuntime(19731):    at com.baasbox.android.ExceptionHandler$1.onError(ExceptionHandler.java:33)
05-13 19:49:05.408: E/AndroidRuntime(19731):    at com.baasbox.android.impl.Dispatcher$Worker.run(Dispatcher.java:174)
05-13 19:49:05.408: E/AndroidRuntime(19731): Caused by: java.lang.NullPointerException
05-13 19:49:05.408: E/AndroidRuntime(19731):    at com.baasbox.android.StreamBody.finishStream(StreamBody.java:37)
05-13 19:49:05.408: E/AndroidRuntime(19731):    at com.baasbox.android.AsyncStream.getFromCache(AsyncStream.java:64)
05-13 19:49:05.408: E/AndroidRuntime(19731):    at com.baasbox.android.NetworkTask.asyncCall(NetworkTask.java:146)
05-13 19:49:05.408: E/AndroidRuntime(19731):    at com.baasbox.android.impl.Task.execute(Task.java:186)
05-13 19:49:05.408: E/AndroidRuntime(19731):    at com.baasbox.android.impl.Dispatcher$Worker.run(Dispatcher.java:170)

I can query the file and it id, but it fails while getting the stream content. My code:

picture.stream(new BaasHandler<BaasFile>() {

    @Override
    public void handle(BaasResult<BaasFile> result) {

        if (result.isSuccess()) {

            try {
                if (result.get() != null) {
                    byte[] pictureData = result.get().getData();

                    if (pictureData != null) {
                        locationImages.add(decodeByteArray(pictureData, 0,
                                pictureData.length));
                        // FIXME
                    }

                }
            } catch (Exception e) {
                Log.e(TAG, e.getMessage());
            }

        } else {
            // TODO no picture data
            Log.e(TAG, "a");
        }

    }
});

For query the file with success I use the following:

Filter where = Filter.where("attachedData.idPublic = '" + locationId + "'", new Object[] {});

BaasFile.fetchAll(where, new BaasHandler<List<BaasFile>>() {
    @Override
    public void handle(BaasResult<List<BaasFile>> res) {

        try {

            if (res.isSuccess()) {
...

ProtocolException when calling plugin

I'm using 0.9.0 server with 0.9.0 Android SDK.

I call my plugins with:
BaasBox box = BaasBox.getDefault();
box.rest(HttpRequest.POST,
"plugin/my.plugin",
new JsonObject().put("my", "data"),
true,
new BaasHandler() {
@OverRide
public void handle(BaasResult res) {
}
});

Most of the time it works fine, however, sometimes I get unhandled Exception:

01-11 20:18:16.295 I/BAASBOX﹕ requested {url ->http://x.x.x.x:x/plugin/my.plugin method: POST, headers ->{...}}

01-11 20:18:16.301 25569-25595/my.package E/AndroidRuntime﹕ FATAL EXCEPTION: Thread-5894
Process: my.package, PID: 25569
java.lang.Error: Got a protocol exception while setting http method
at com.baasbox.android.HttpUrlConnectionClient.setupConnectionForRequest(HttpUrlConnectionClient.java:240)
at com.baasbox.android.HttpUrlConnectionClient.execute(HttpUrlConnectionClient.java:154)
at com.baasbox.android.NetworkTask.asyncCall(NetworkTask.java:151)
at com.baasbox.android.NetworkTask.parseResponse(NetworkTask.java:74)
at com.baasbox.android.NetworkTask.asyncCall(NetworkTask.java:152)
at com.baasbox.android.impl.Task.execute(Task.java:189)
at com.baasbox.android.impl.Dispatcher$Worker.run(Dispatcher.java:170)
Caused by: java.net.ProtocolException: content-length promised 7 bytes, but received 0
at com.android.okhttp.internal.http.RetryableSink.close(RetryableSink.java:50)
at com.android.okio.RealBufferedSink.close(RealBufferedSink.java:174)
at com.android.okio.RealBufferedSink$1.close(RealBufferedSink.java:142)
at com.baasbox.android.HttpUrlConnectionClient.copyStream(HttpUrlConnectionClient.java:261)
at com.baasbox.android.HttpUrlConnectionClient.addBody(HttpUrlConnectionClient.java:248)
at com.baasbox.android.HttpUrlConnectionClient.setupConnectionForRequest(HttpUrlConnectionClient.java:224)
            at com.baasbox.android.HttpUrlConnectionClient.execute(HttpUrlConnectionClient.java:154)
            at com.baasbox.android.NetworkTask.asyncCall(NetworkTask.java:151)
            at com.baasbox.android.NetworkTask.parseResponse(NetworkTask.java:74)
            at com.baasbox.android.NetworkTask.asyncCall(NetworkTask.java:152)
            at com.baasbox.android.impl.Task.execute(Task.java:189)
            at com.baasbox.android.impl.Dispatcher$Worker.run(Dispatcher.java:170)

GCM registration issue

I get the following NPE when I try to use signed APK. It works if I run it in debug mode. I have added both (debug and signed) SHA1 to the developer console and G+ login and other APIs work well. I use the main version of the Android SDK - as suggested in #40

Any ideas what can go wrong?

    java.lang.RuntimeException: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[])' on a null object reference
            at com.baasbox.android.ExceptionHandler$1.onError(ExceptionHandler.java:33)
            at com.baasbox.android.impl.Dispatcher$Worker.run(Dispatcher.java:174)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[])' on a null object reference
            at com.baasbox.android.impl.GCMWrapper.registerGCM0(GCMWrapper.java:85)
            at com.baasbox.android.impl.GCMWrapper.registerGCM(GCMWrapper.java:77)
            at com.baasbox.android.BaasCloudMessagingService.registerWithGoogle(BaasCloudMessagingService.java:85)
            at com.baasbox.android.BaasCloudMessagingService.access$200(BaasCloudMessagingService.java:22)
            at com.baasbox.android.BaasCloudMessagingService$RegisterMessaging.asyncCall(BaasCloudMessagingService.java:370)
            at com.baasbox.android.BaasCloudMessagingService$RegisterMessaging.asyncCall(BaasCloudMessagingService.java:346)
            at com.baasbox.android.impl.Task.execute(Task.java:189)
            at com.baasbox.android.impl.Dispatcher$Worker.run(Dispatcher.java:170)

Change value of the object field inside an array

Hello guys,

Unfortunately handling of json arrays is not described well in Android SDK documentation, yet. Could you please help me, how can I change certain field of the object inside an array like this:

"messages": [
{
"userNumber": "142125235235",
"accepted": 1
}

I'm trying this way, but it doesn't work:

optJsonBody.putString("data", "2");
cli.rest(HttpRequest.PUT,
"document/sms/" + messsage.id + "/.messages[0].accepted",
optJsonBody,
true,
new BaasHandler() { ...}

null pointer in streambody

BaasAsset.streamAsset("assetName",new BaasHandler<byte[]>() {
@OverRide
public void handle(BaasResult<byte[]> res){
if(res.isSuccess()) {
byte[] data = res.value();
} else {
Log.e("ERROR","Error while retrieving asset",res.error());
}
}
});

Results in null pointer exception:
java.lang.NullPointerException: Attempt to invoke virtual method 'void com.baasbox.android.FixedByteArrayOutputStream.close()' on a null object reference
at com.baasbox.android.StreamBody.finishStream(StreamBody.java:40)

BaasFile url to get file content

Hello,
In my test app, a user creates an image that I upload to baasbox as baasfile that contains custom data in attachedData field. Later on I want to display user created images. , I can get his collection by BaasFile.fetchAll( handler);

There are libraries like picasso that cache images in memory/disk and display nicely in imageview if you supply them an image url.

BaasFile doesn't seem to have a url to get file contents. You can use getData or stream method and create a bitmap from it but then I can't use it in these 3rd party lib

Thanks
-Anil

Exception working with Social Login method: BaasUser.signupWithProvider ()

I was working with the method BaasUser.signupWithProvider to login an user into Facebook according to the API Reference but I recieved the following exception:

"java.lang.NullPointerException\n\tat com.baasbox.controllers.Social.extractOAuthTokensFromRequest(Social.java:111)\n\tat com.baasbox.controllers.Social.loginWith(Social.java:139)"

Then, I tried to login using the client.rest() method, it worked fine, but it returns a JsonObject and I don't know how to convert it in a BaasUser Object.

Filter count documents function

I´m having a trouble while filtering the count documents:

Filter filter= BaasQuery.builder().where("locationId = '" + locationPid + "'").filter();

        BaasDocument.count(CHECKIN_COLLECTION, filter, new BaasHandler<Long>() {
            @Override
            public void handle(BaasResult<Long> res) {
                if (res.isSuccess()) {
                    Toast.makeText(getApplicationContext(), "" + res.value(), Toast.LENGTH_LONG).show();
                    if (res.value() > 0) {

                    }
                }
            }
        });

This always return the total of the collection, even if the locationPid doesnt has nothing associated.

BaasDocument.count does not apply filter criteria

BaasDocument.count always returns the count of the whole collection regardless what filtering criteria you use. Same filter does the job with fetch but does not work with count. It might be caused by this:

private static final class Count extends NetworkTask<Long> {
    private final String collection;
    private final RequestFactory.Param[] params;

    protected Count(BaasBox box, String collection, BaasQuery.Criteria filter, int flags, BaasHandler<Long> handler) {
        super(box, flags, handler);
        this.collection = collection;
        this.params = filter == null ? null : filter.toParams();
    }

    @Override
    protected Long onOk(int status, HttpResponse response, BaasBox box) throws BaasException {
        return parseJson(response, box).getObject("data").getLong("count");
    }

    @Override
    protected HttpRequest request(BaasBox box) {
        String ep = box.requestFactory.getEndpoint("document/{}/count", collection);
        if (params == null) {
            return box.requestFactory.get(ep, params);
        } else {
            return box.requestFactory.get(ep);
        }
    }

Should be:

@OverRide
protected HttpRequest request(BaasBox box) {
String ep = box.requestFactory.getEndpoint("document/{}/count", collection);
if (params == null) {
return box.requestFactory.get(ep);
} else {
return box.requestFactory.get(ep, params);
}
}

There is also an issue with permissions. Count includes every document in the collection, even those that the user doesn't have permission for.

Thank you.

Planned Milestones for Android

Hi,

are there any plans, for the next Milestones on Android? Unfortunately there are problems with the Social Login in the current Android SDK which makes it quite difficult for me to go on with my project at the moment.

I appreciate any feedback.

Best,
Eray

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.