Good morning,
Due to the next 01/11 disappears the free mode for versions 3.X, I am obliged to migrate to 4.X. to adhere to the developer mode since my app has 19 tables …
The id of my app is 2A0C76E5-9B6D-1781-FF2E-338F61700800 and although I have developed the android version I am currently coding the IOS version.
My question is … do I have to modify all the BackEndLess statements in my app or the 4.X versions support all 3.X instructions?
I have consulted the migration document and I only see an example transition for the query but I have not seen anything for the update nor for the deletion of both table and file objects.
I need your help …
Thank you very much.
Hi Joan,
The 4.x version requires you to use the newer builds of the SDKs. There are changes in the SDKs and how objects are persisted. The most noticeable change is the relations are not created right away when you store an object. In order to create a relation, a separate API call is required. This is documented in greater detail here:
https://backendless.com/docs/ios/doc.html#related_objects
and here:
https://backendless.com/docs/ios/doc.html#data_relations_api_set_add_ios
Additionally, there are changes in how collections of objects are returned from the "find’ requests. Previously, the server side returned BackendlessCollection, now you get back an array. To get a count of objects in a table or for a whereClause query, you can use the following API:
https://backendless.com/docs/ios/doc.html#data_get_object_count
Hope this helps.
Regards,
Mark
Good mornig,
I amb already migrating from V3 to V4 developer pricing and I have started to perform tests to change all my Asynchronous Api statements and I can not find the way to establish the relationship between a table and a geopoint.
Below there is an example of one save statement of “DatosAdicionalesDeUsuario” table where I add both the record and the geopoint but the relationship is not established. Wat is missing to establish the relationship ?
DatosAdicionalesDeUsuario datosAdicionalesDeUsuario = new DatosAdicionalesDeUsuario();
datosAdicionalesDeUsuario.setUsuarioConectado(false);
datosAdicionalesDeUsuario.setUserName(username);
.
.
.
// in V3:
//GeoPoint point = new GeoPoint();
//point.setLatitude(latitud);
//point.setLongitude(longitud);
//datosAdicionalesDeUsuario.setPosicion(point);
Backendless.Data.of( DatosAdicionalesDeUsuario.class ).save( datosAdicionalesDeUsuario, new AsyncCallback<DatosAdicionalesDeUsuario>()
{
@Override
public void handleResponse(final DatosAdicionalesDeUsuario datosAdicionalesDeUsuario )
{
List<String> categories = new ArrayList<String>();
categories.add( "DatosAdicionalesDeUsuario" );
Map<String, Object> meta = new HashMap<String, Object>();
meta.put( "posicion", “ejemplo” );
Backendless.Geo.savePoint( latitud, longitud, categories, meta,
new AsyncCallback<GeoPoint>()
{
public void handleResponse( GeoPoint geoPoint )
{
Toast.makeText(Pruebas.this, "OK", Toast.LENGTH_LONG).show();
GeoPoint point = new GeoPoint();
point.setLatitude( 40.7148 );
point.setLongitude( -74.0059 );
point.addCategory( "taxi" );
point.addMetadata( "service_area", "NYC" );
point = Backendless.Geo.savePoint( point );
ArrayList<GeoPoint> location = new ArrayList<GeoPoint>();
location.add( point );
}
@Override
public void handleFault( BackendlessFault backendlessFault )
{
Toast.makeText(Pruebas.this, "Error alta de geoPoint“, Toast.LENGTH_LONG).show();
}
});
}
@Override
public void handleFault( BackendlessFault fault )
{
Toast.makeText(Pruebas.this, "Error alta de registro”, Toast.LENGTH_LONG).show();
}
} );
Regards,
Sorry, I have included by mistake the following statements:
GeoPoint point = new GeoPoint();
point.setLatitude( 40.7148 );
point.setLongitude( -74.0059 );
point.addCategory( "taxi" );
point.addMetadata( "service_area", "NYC" );
point = Backendless.Geo.savePoint( point );
ArrayList<GeoPoint> location = new ArrayList<GeoPoint>();
location.add( point );
Regards,
is this valid? … or has it been a bad attempt?
HashMap<String, Object> parentObject = new HashMap<String, Object>();parentObject.put( “objectId”, “OBJECTID RECORD OF DatosAdicionalesDeUsuario” ); HashMap<String, Object> childObject = new HashMap<String, Object>();childObject.put( “objectId”, “OBJECID geopoint” ); ArrayList<Map> children = new ArrayList<Map>();children.add( childObject ); Backendless.Data.of( “DatosAdicionalesDeUsuario” ).setRelation( parentObject, “posicion”, children, new AsyncCallback<Integer>(){ @Override public void handleResponse( Integer response ) { Log.i( “MYAPP”, “relation has been set” ); } @Override public void handleFault( BackendlessFault fault ) { Log.e( “MYAPP”, "server reported an error - " + fault.getMessage() ); }} );
You can use the same Relations API to set a relation from a data object to geo point. Here is an example exactly for Data-to-Geo relation: https://backendless.com/docs/android/doc.html#establishing-relations-with-geo-points-via-api
I have already tried this and it does not work for me … is there an asynchronous version?
I have the “posicion” Data-to-Geo column in the parent table “DatosAdicionalesDeUdsuario”.
Have you tried using GeoPoint objects instead of Maps?
I was able to establish the relationship in asynchronous mode between a Data Object and a geoPoint as follows:
Backendless.Data.of( DatosAdicionalesDeUsuario.class ).save( datosAdicionalesDeUsuario, new AsyncCallback<DatosAdicionalesDeUsuario>()
{
public void handleResponse(final DatosAdicionalesDeUsuario datosAdicionalesDeUsuario )
{
List<String> categories = new ArrayList<String>();
categories.add( “DatosAdicionalesDeUsuario” );
Map<String, Object> meta = new HashMap<String, Object>();
meta.put( "posicion", "ok" );
idDatosAdicionales = datosAdicionalesDeUsuario.getObjectId();
Backendless.Geo.savePoint( 41.4060, 2.1935, categories, meta,
new AsyncCallback<GeoPoint>()
{
@Override
public void handleResponse( GeoPoint geoPoint )
{
idPoint = geoPoint.getObjectId();
HashMap<String, Object> parentObject = new HashMap<String, Object>();
parentObject.put( "objectId", idDatosAdicionales );
HashMap<String, Object> childObject = new HashMap<String, Object>();
childObject.put( "objectId", idPoint );
ArrayList<Map> children = new ArrayList<Map>();
children.add( childObject );
Backendless.Data.of( "DatosAdicionalesDeUsuario" ).setRelation( parentObject, "posicion", children,
new AsyncCallback<Integer>()
{
public void handleResponse( Integer response )
{
Toast.makeText(Pruebas.this, "Relacion OK", Toast.LENGTH_LONG).show();
}
public void handleFault( BackendlessFault fault )
{
Toast.makeText(Pruebas.this, "Relacion KO", Toast.LENGTH_LONG).show();
}
} );
}
public void handleFault( BackendlessFault backendlessFault )
{
Toast.makeText(Pruebas.this, "Geopoint KO", Toast.LENGTH_LONG).show();
}
});
}
public void handleFault( BackendlessFault fault )
{
Toast.makeText(Pruebas.this, "Error en el alta", Toast.LENGTH_LONG).show();
}
} );