hypertrack - always show Device disconnected on dashboard objective c iOS - ios

i am creating action "visit" after new user create in objective c iOS but on dashboard device disconnected show against user nor can see location through url or action id. here is screen short.
-(void)createUser{
[HyperTrack initialize:#"......."];
[HyperTrack requestAlwaysAuthorizationWithCompletionHandler:^(BOOL authorized) {
//handle authorization status, if needed
}];
[HyperTrack requestMotionAuthorization];
[HyperTrack getOrCreateUser:#"test1" _phone:#"12345" :#"12" completionHandler:^(HyperTrackUser * _Nullable user, HyperTrackError * _Nullable error) {
if (user) {
// Handle getOrCreateUser API success here
NSLog(#"User Created");
NSLog(#"%#",user.id);
[self createAction:user.id];
} else {
// Handle createUser error here, if required
NSLog(#"User Created error %#",error);
}
}];
}
-(void)createAction:(NSString *)userId{
HyperTrackActionParams* actionParams = [[HyperTrackActionParams alloc] init];
[actionParams setType:#"visit"];
[actionParams setUserId:userId];
[HyperTrack createAndAssignAction:actionParams :^(HyperTrackAction * action, HyperTrackError * error) {
if (error) {
// Handle createAction API error here
return;
}
if (action) {
// Handle createAction API success here
NSLog(#"%#",action.id);
NSLog(#"%#",action.trackingUrl);
}
}];
}

My pod was outdated. I reinstalled pod with pod 'HyperTrack', '~> 0.7'. Now its working fine.

Related

HomeKit error: HMErrorCodeObjectNotAssociatedToAnyHome (code 12) when adding an actionSet to a trigger

The following code is used to create a home kit automation that switches off an outlet. Starting on iOS 16 it returns an error (HMErrorCodeObjectNotAssociatedToAnyHome, code 12) when the trigger is told to add the action set.
I marked the line using // error, "code 12" (HMErrorCodeObjectNotAssociatedToAnyHome). Also, HKActionSetCreateShouldContinue() is just a function to log errors and returns true if the error was <nil>.
The error first appeared in iOS 16, the same code runs smooth on iOS 15. I did not find any complaints about such an error in Apple's forums.
Does anyone have the same issue and/or know what's wrong for iOS 16?
// fireDate is rastered to minutes. in example from 1669971067.404232 to 1669971060
NSDate* const fireDate = [NSDate ...]
HMTimerTrigger* const trigger = [[HMTimerTrigger alloc] initWithName:triggerName
fireDate:fireDate
timeZone:nil
recurrence:nil
recurrenceCalendar:nil];
[home addActionSetWithName:actionSetName
completionHandler:^(HMActionSet* _Nullable actionSet, NSError* _Nullable error) {
if (!HKActionSetCreateShouldContinue(block, error, created, #"home/addActionSet")) {
return;
}
[actionSet addAction:switchOffAction
completionHandler:^(NSError* _Nullable add_char_error) {
/* Only check for errors and log */
HKActionSetCreateShouldContinue(block, add_char_error, created, #"actionSet/switchOffAction");
}];
[home addTrigger:trigger
completionHandler:^(NSError* _Nullable home_error) {
if (!HKActionSetCreateShouldContinue(block, home_error, created, #"home/addTrigger")) {
return;
}
[trigger addActionSet:actionSet
completionHandler:^(NSError* _Nullable trigger_error) {
// error, "code 12" (HMErrorCodeObjectNotAssociatedToAnyHome)
if (!HKActionSetCreateShouldContinue(block, trigger_error, created, #"trigger/addActionSet")) {
return;
}
[trigger enable:YES
completionHandler:^(NSError* _Nullable error) {
if (!HKActionSetCreateShouldContinue(block, home_error, created, #"trigger/enable") || block == nil) {
return;
}
dispatch_async(dispatch_get_main_queue(), ^{
block(actionSet, trigger, switchOffAction);
});
}];
}];
;
}];

Unable to localize Face Id popup for non-matching face

It seems like Face Id is ignoring localizedFallbackTitle and localizedReason. However localizedCancelTitle is working fine. Does anyone know how to get it work?
My code:
LAContext *context = [[LAContext alloc] init];
if ([context respondsToSelector:#selector(setLocalizedCancelTitle:)]) {
context.localizedCancelTitle = [Language get:CANCEL alter:nil];
}
if ([context respondsToSelector:#selector(setLocalizedFallbackTitle:)])
{
context.localizedFallbackTitle = [Language get:TRY_AGAIN alter:nil];
}
NSError *error = nil;
if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthentication error:&error]) {
[context evaluatePolicy:LAPolicyDeviceOwnerAuthentication
localizedReason:[Language get:AUTHRNTICATE_USING_YOUR_FACE alter:nil] reply:^(BOOL success, NSError *error) {
//code
}
Screenshot:
I want to localize everything on this popup if possible.
Note: Attached screenshot is taken on simulator. I have also checked
it on real device but the result is same. Also, for Touch id it is working properly.
According to this Post, there is no API for changing the Reason in between the auth process.
localizedReason
The app-provided reason for requesting authentication, which displays in > the authentication dialog presented to the user.
You can use BiometricAuthentication to show your message.
BioMetricAuthenticator.authenticateWithBioMetrics(reason: "", success: {
// authentication successful
}, failure: { [weak self] (error) in
// do nothing on canceled
if error == .canceledByUser || error == .canceledBySystem {
return
}
// device does not support biometric (face id or touch id) authentication
else if error == .biometryNotAvailable {
self?.showErrorAlert(message: error.message())
}
// show alternatives on fallback button clicked
else if error == .fallback {
// here we're entering username and password
self?.txtUsername.becomeFirstResponder()
}
// No biometry enrolled in this device, ask user to register fingerprint or face
else if error == .biometryNotEnrolled {
self?.showGotoSettingsAlert(message: error.message())
}
// Biometry is locked out now, because there were too many failed attempts.
// Need to enter device passcode to unlock.
else if error == .biometryLockedout {
// show passcode authentication
}
// show error on authentication failed
else {
self?.showErrorAlert(message: error.message())
}
})

Getting user infos using ObjectiveDropboxOfficial framework

I am using ObjectiveDropboxOfficial framework for Dropbox integration within Objective-C app (due to the deprecation of v1 dropbox api).
Framework link
I am trying to get logged in dropbox user info (email, name, etc). Here is my code:
DropboxClient *client=[DropboxClientsManager authorizedClient];
[[client.usersRoutes getCurrentAccount]
response:^_Nonnull(DBUSERSBasicAccount *response, DBError *dberror)
{
// loginLabel.text=[NSString stringWithFormat: #"%#\n%#", account.name, account.email];
return response;
}
}];
This code doesn't work and additionnally causes weird error from xcode: enter image description here
The method definition is:
- (DBRpcTask<DBUSERSBasicAccount *, DBUSERSGetAccountError *> *_Nonnull) getAccount:(NSString *_Nonnull)accountId;
- (DBRpcTask<TResponse, TError> *_Nonnull)response:
(void (^_Nonnull)(TResponse _Nullable, TError _Nullable,
DBError *_Nullable))responseBlock;
I was stuck with this for a whole day, any help would be appreciated:
1- How to get user infos using the framework, or
2- What is causing the error and how should that Nonnull method be called?
Thank you in advance
So finally after 2 days of struggling I found the response :
DropboxClient *client = [DropboxClientsManager authorizedClient];
if(client)
{
[[client.usersRoutes getCurrentAccount] response:^(DBUSERSFullAccount *account, DBNilObject *obj, DBError *error) {
if (error != nil) {
NSLog(#"Error %#", error.errorContent);
}
if (account != nil) {
NSLog(#"User's name %#", account.name.displayName);
}
if(self.hud)
[self.hud hideAnimated:YES];
}];
I hope this would save another developer's energy and mental health :)

QuickBlox video chat: QBRequest.logInWithUserEmail vs QBChat.instance().connectWithUser

I have a simple QuickBlox chat app built by following the iOS tutorial:
http://quickblox.com/developers/Sample-webrtc-ios#Sources
I've successfully created a user and logged them in. However, I run into an error when I try to initiate a session: "You have to be logged in in order to use Chat API".
let newSession: QBRTCSession = QBRTCClient.instance().createNewSessionWithOpponents(["12498970"], withConferenceType: QBRTCConferenceType.Video)
I'm able to resolve this by adding QBChat.instance().connectWithUser each time I open it:
QBChat.instance().connectWithUser(user!) { (error) in
if error != nil {
print("error: \(error)")
}
else {
print("login to chat succeeded")
}
}
But somehow this seems weird because I have to either cache the password or prompt the user to enter their password each time the app opens. It seems strange that the QBSession.currentSession().currentUser is still valid, but the QBChat user has been invalidated. What is the best practice for accomplishing this? In all the samples, the passwords are hardcoded. This doesn't seem like a great solution.
I ended up following examples in Q-municate, which is an app the Quickblox folks built to basically demonstrate their whole package, as well as provide an actual solution for whatever your chat needs are. I have some other custom stuff and don't need a lot of the functionality so I'm still trying to dig through the details of how they implement it. The link to Q-municate:
http://quickblox.com/developers/Q-municate#1._Get_the_source_code.
In their login flow, they use the QMApi module written for Q-municate:
[[QMApi instance] loginWithEmail:email
password:password
rememberMe:weakSelf.rememberMeSwitch.on
completion:^(BOOL success)
{
[SVProgressHUD dismiss];
if (success) {
[[QMApi instance] setAutoLogin:weakSelf.rememberMeSwitch.on
withAccountType:QMAccountTypeEmail];
[weakSelf performSegueWithIdentifier:kTabBarSegueIdnetifier
sender:nil];
}
}];
In loginWithEmail, their settingsManager caches this login:
[weakSelf.settingsManager setLogin:email andPassword:password];
which is actually just a way to cache the password in SSKeyChain.
[SSKeychain setPassword:password forService:kQMAuthServiceKey account:login];
Later, when you return to the app, they call autologin:
if (!self.isAuthorized) {
if (self.settingsManager.accountType == QMAccountTypeEmail && self.settingsManager.password && self.settingsManager.login) {
NSString *email = self.settingsManager.login;
NSString *password = self.settingsManager.password;
[self loginWithEmail:email password:password rememberMe:YES completion:completion];
}
else if (self.settingsManager.accountType == QMAccountTypeFacebook) {
[self loginWithFacebook:completion];
}
else {
if (completion) completion(NO);
}
}
else {
if (completion) completion(YES);
}
where self.settingsManager.password pulls the password from SSKeychain:
NSString *password = [SSKeychain passwordForService:kQMAuthServiceKey account:self.login];
autoLogin is called when the main chat tab is loaded. That makes our classic call to connectToChat:
[[QMApi instance] autoLogin:^(BOOL success) {
if (!success) {
[[QMApi instance] logoutWithCompletion:^(BOOL succeed) {
//
[weakSelf performSegueWithIdentifier:#"SplashSegue" sender:nil];
}];
} else {
// subscribe to push notifications
[[QMApi instance] subscribeToPushNotificationsForceSettings:NO complete:^(BOOL subscribeToPushNotificationsSuccess) {
if (!subscribeToPushNotificationsSuccess) {
[QMApi instance].settingsManager.pushNotificationsEnabled = NO;
}
}];
[weakSelf connectToChat];
}
}];
So technically the docs are doing the right thing by logging in to chat every time the app opens and chat is no longer connected. There's just a much more complex but secure way to store that password so the user doesn't have to reenter it.
TLDR: The way it works in my code (and in swift) is:
On login:
QBRequest.logInWithUserEmail(email, password: password, successBlock: { (response, user) in
SSKeychain.setPassword(password, forService: "kMyAppLoginServiceKey", account: email)
}) { (errorResponse) in
print("Error: \(errorResponse)")
self.simpleAlert("Could not log in", defaultMessage: nil, error: nil)
}
Whenever the chat view loads:
if !QBChat.instance().isConnected() {
QBRTCClient.initializeRTC()
QBRTCClient.instance().addDelegate(self)
let user = QBSession.currentSession().currentUser
let password = SSKeychain.passwordForService("kMyAppLoginServiceKey", account: user?.email!)
user!.password = password
QBChat.instance().addDelegate(self)
QBChat.instance().connectWithUser(user!) { (error) in
if error != nil {
print("error: \(error)")
}
else {
print("login to chat succeeded")
}
}
}

NSURLERRORDOMAIN--1012E: (null) on Bluemix

I am trying to connect Bluemix remote DB as the following:
IMFDataManager.sharedInstance().remoteStore("people", completionHandler: { (store:CDTStore!, error:NSError!) -> Void in
var query:CDTCloudantQuery = CDTCloudantQuery(dataType: "Person")
store.performQuery(query, completionHandler: { (results:[AnyObject]!, error:NSError!) -> Void in
var myData = results as! [Person]
println(myData.count)
})
})
For some reason I get the following error message.
I have checked the documentation and couldn't find any relevant about authentication.
2015-06-01 19:05:38.672 helloBluemix[34398:2621801] [INFO] [IMFData] Authorization failure. Http status 401 received on request to https://mobile.ng.bluemix.net/imfdata/api/v1/apps/5fc5cfd9-73db-432b-a1f5-3f2824e1c5ec/peoples/_find
2015-06-01 19:05:38.676 helloBluemix[34398:2621799] [ERROR] [IMFData] Error occured during query. URL: https://mobile.ng.bluemix.net/imfdata/api/v1/apps/5fc5cfd9-73db-432b-a1f5-3f2824e1c5ec/peoples/_find. queryJSON: {
selector = {
"#datatype" = Person;
};
} NSURLERRORDOMAIN--1012E: (null)
Same problem here.
I did some changes to my code but could not think of something I changed in the Bluemix interaction code...
When I previously had authorization errors I was able to fix it by adjusting the access rights for the database in the "Cloudant Dashboard". However, it is now set to "Read" and "Write" for "Everybody else", so that should not be an issue.
I was getting the same error before I set user permissions on my IMFDataManager object after I got a reference to it:
IMFDataManager *manager = [IMFDataManager sharedInstance];
[manager remoteStore:#"<your_db_name>" completionHandler:^(CDTStore *store, NSError *error) {
if (error) {
NSLog(#"there was an error fetching or creating the remote store");
} else {
NSLog(#"remote store success");
[manager setCurrentUserPermissions:DB_ACCESS_GROUP_MEMBERS forStoreName:#"<your_db_name>" completionHander:^(BOOL success, NSError *error) {
if (error) {
NSLog(#"error setting permissions");
} else {
NSLog(#"set permissions successfully");
}
}];
}
}];

Resources