I want use Huawei Push Kit in my Appcelerator Titanium app with Hyperloop.
var tokenString = '';
var Activity = require('android.app.Activity');
var ActivityToken = require('com.huawei.hms.aaid.HmsInstanceId');
try{
const activity = new Activity(Ti.Android.currentActivity);
tokenString = ActivityToken.getInstance(activity).getToken(appID, "HCM");
console.log('tokenString', tokenString);
}
catch (e){
console.log(e);
}
But I receive error: "operation in MAIN thread prohibited"
How do I run the code in a separate thread?
You could try the Automatic Initialization, by calling the setAutoInitEnabled(boolean enable) method in HmsMessaging.
The applied token is returned through the onNewToken() method after completing the configuration.