Support Topics Documentation Slack YouTube Blog

Register device cause crash


(Allan) #1

My apps start getting crash when register device
APPLICATION_ID 161CA8CE-7AC3-2596-FF77-73632D3ED600
It crashed both on all android and ios devices.
On android device, it return a success message “register device: Device has been subscribed to channel userwCF3H4FNrmWQ5IshvmyAGUToDhf2”, but then 30 seconds after, it crash with “Could not register device on Backendless server: timeout”.
For iOS, app get freeze with register device function, no success or error message and finally crash.
I have been using those code in past 4 months, the problem start on last Friday morning and was solved for while and get back this morning,
See this http://support.backendless.com/t/urgent-register-device-cause-crash
java.lang.RuntimeException: Could not register device on Backendless server: timeout
at com.backendless.push.BackendlessPushService.onError(BackendlessPushService.java:88)
at com.backendless.push.BackendlessPushService$1.handleFault(BackendlessPushService.java:252)
at com.backendless.Messaging$2.handleFault(Messaging.java:255)
at com.backendless.async.message.AsyncMessage$FaultHandler.handle(AsyncMessage.java:83)
at com.backendless.async.message.AsyncMessage.handleCallback(AsyncMessage.java:41)
at com.backendless.core.AndroidCarrier$1.handleMessage(AndroidCarrier.java:37)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Android code


try {
 List<String> channels = new ArrayList<String>();
 channels.add(channel);
 Calendar cal = Calendar.getInstance();
 cal.add(Calendar.YEAR, 10);
 Date expiration = cal.getTime();


 Log.e(“register device”, “expiration ” + expiration);
 Log.e(“register device”, “channels ” + channels);


 Backendless.Messaging.registerDevice(context.getString(R.string.google_project_number), channels, expiration, new AsyncCallback<Void>() {
 @Override
 public void handleResponse(Void response) {
 if(DEBUG) Timber.v(“Device has been subscribed to channel ” + channel);
 Log.e(“register device”, “response ” + response);


 Log.e(“register device”, “Device has been subscribed to channel ” + channel);




 }


 @Override
 public void handleFault(BackendlessFault fault) {
 if(DEBUG) Timber.v(“Device subscription failed. ” + fault.getMessage());
 Log.e(“register device”, “Device subscription failed. ” + fault.getMessage());
 }
 });
 } catch (Exception e) {
 e.printStackTrace();
 Log.e(“register device”, “Device subscription failed. ” + e.getMessage());
 return false;
 }

iOS code


-(void) subscribeToPushChannel: (NSString *) channel {
 NSLog(@"subscribeToPushChannel %@", channel);
 if (!_isSubscribed) {
 channel = [self safeChannel:channel];
 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
 NSData *token = [defaults objectForKey:@"backendless_deviceToken"];
 
 if (token) {
 @try {
 NSCalendar *cal = [NSCalendar currentCalendar];
 NSDate *expiration = [cal dateByAddingUnit:NSCalendarUnitYear value:10 toDate:[NSDate date] options:0];
 NSString * deviceRegistrationId = [backendless.messaging registerDevice:token channels:@[channel] expiration:expiration];
 
 NSLog(@"subscribeToPushChannel success deviceRegistrationId: %@", deviceRegistrationId);
 _isSubscribed = YES;
 }
 @catch (Fault * fault) {
 NSLog(@"subscribeToPushChannel FAULT = %@ <%@>", fault.message, fault.detail);
 }@finally {
 
 }
 }
 }
}


(Vladimir Upirov) #2

Hello Allan

We’ve create an internal ticket BKNDLSS-16710 for investigation your issue, and we will notify you here about any result

And I’ve switched mode of the topic from private to normal, private topic is available only for Managed Backendless and Backendless PRO plans

Thanks, Vladimir


(Vladimir Upirov) #3

Do you still have the problem?


(Allan) #4

The problem was gone yesterday afternoon at 3pm, but it’s backed today about half hour ago. The problem seem to come back at about 9:30am every day since last Friday.


(Allan) #5

It’s working now.