Support Topics Documentation Slack YouTube Blog

Backendless.Messaging.registerDeviceOnServer() not working


(FlipTrip) #1

I’ve tried to register some Android device on server with method registerDeviceOnServer() but I’m getting the following error: “error” -> “BackendlessException{ code: ‘Server.Processing’, message: ‘unable to adapt parameter to a method argument type. unable to adapt string to class com.backendless.datamodel.enums.OperatingSystem. String value - Windows 10’ }”

My scenario would bo something like that; each device has its own channel for push notifications:

  • Device A sends join request to device B (device A would like to subscribe to push messages of device’s B channel)
  • After device B approves join request I call backendless business logic Backendless.Events.dispatch(“approveJoinRequest”)
  • In business logic after I join A to B via Group and User table (look at the code) I would like to register A to push messages of B’s channel
 PushObject pushObject = convertToPushObject((HashMap<String, Object>) eventArgs.get(KEY_PUSH_OBJECT));
 try {
 BackendlessUser user = Backendless.UserService.findById(pushObject.getSenderId());
 // Remove applicant from his current Group... 
 GroupEventHandler.removeFromGroup(user);
 // ...and join him to new Group 
 GroupEventHandler.joinToGroup(user, pushObject.getGroupToJoin());
 List<String> channels = new ArrayList<String>();
 String channel = "ch"+pushObject.getGroupToJoin();
 channels.add(channel);
 // Register applicant to new channel 
 String deviceToken = pushObject.getSendersDeviceToken();
 Backendless.Messaging.registerDeviceOnServer(deviceToken, channels, 4000000000000L); // Tuesday, October 2, 2096 7:06:40 AM UTC);
 } catch (Exception e) {
 e.printStackTrace();
 args.put(KEY_ERROR, e.toString());
 }

So, is this even possible because according to mentioned error it seems that isn’t (yes, I’m aware that I’m running CodeRunner from Windows 10 OS).


(Sergey Chupov) #2

Hi,

Are you trying to register CodeRunner as a device to receive push notifications?