API Call Syntax Using JLTMDbClient - ios

I've just started accessing TMDB for an iOS app using https://github.com/JaviLorbada/JLTMDbClient - I searched for a solution using relevant search terms before posting and didn't see any other questions asked about this.
When I use the author's example code it works as it should and fetchedData contains a list of popular movies:
[[JLTMDbClient sharedAPIInstance] GET:kJLTMDbMoviePopular withParameters:nil andResponseBlock:^(id response, NSError *error) {
if(!error){
fetchedData = response;
NSLog(#"Popular movies: %#", fetchedData);
}
}];
What I need is to return a list of movies for a specific actor (stored in variable 'name', defined as an NSString). I read the documentation on Github and also TMDB.com to understand the syntax, but I just can't seem to get it.
I tried (unsuccessfully, no error but nothing posted from NSLog):
[[JLTMDbClient sharedAPIInstance] GET:kJLTMDbPerson withParameters:#{#"id":name} andResponseBlock:^(id response, NSError *error) {
if(!error){
fetchedData = response;
NSLog(#"Actors movies: %#", fetchedData);
}
}];
Also I'm unsure which of the following I should be using:
kJLTMDbPerson
kJLTMDbSearchPerson
Thanks in advance for any responses.

Related

I can not get Branch install parameters after opening app from Shared Link in iOS

I am sharing link with Branch.io , but when I am installing app from the link in my didFinishLaunchingWithOptions, not getting the Branch parameters.
[[Branch getInstance] initSessionWithLaunchOptions:launchOptions isReferrable:YES andRegisterDeepLinkHandler:^(NSDictionary * _Nullable params, NSError * _Nullable error) {
if (!error) {
// params are the deep linked params associated with the link that the user clicked -> was re-directed to this app
// params will be empty if no data found
// ... insert custom logic here ...
NSLog(#"branch params.description: %#", params.description);
NSLog(#"branch params: %#", params);
} else {
NSLog(#"branch error: %#", error);
}
}];
branch params don't have the embedded properties in it, and also it cant detect it is installed from Link.
It always prints:
branch params: {
"+clicked_branch_link" = 0;
"+is_first_session" = 0;
}
I have set all the key information and associate domains in Project.
What can be the reason for this, is it related to ios version? or Branch sdk problem?
Thanks in advance.

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 :)

How to read the body of the request in Azure App Service?

I am trying to create an EasyAPI in Azure App Service (migrated from Azure Mobiles Services). The message is sent from an iOS app using the following command in swift:
let query: Dictionary<String, AnyObject> = ["name": theName]
let param: Dictionary<String, AnyObject> = ["collectionName": theCollectionName, "query": query]
AOAppDelegate.client!.invokeAPI("FMDataAPI", body: param, HTTPMethod: "POST", parameters: nil, headers: nil, completion: {(objects, httpResponse, error) in
if error == nil {
//Process response
} else {
print(error!.userInfo)
}
})
In the API I have the following Javascript code within the EasyAPI MyEasyAPI:
module.exports = {
"post": function (req, res, next) {
console.log("---------------------------------------")
console.log(req.body)
},
But body stays undefined.
Any suggestions?
Thanks,
GA
You need to adjust the app before the easy API gets called. By the time you are adding the middleware, it's too late. Fortunately, bodyparser is already implemented for you. Note that generally, you need to be doing something that expects a body - like a POST - to do this.
Since this is a migrated mobile service, you need to follow the instructions for mobile services - things that are documented for App Service are generally only available for upgraded sites (that is, sites running on App Service that have not been migrated).
Good news is that we have some help there if you need it. Check out the node module: https://github.com/Azure/azure-mobile-apps-node-compatibility for more information.
Thanks for your suggestions.
I reported an issue in the github project of the Azure Mobile Apps iOS client and they suggested that the problem could be in the version of the node package azure-mobile-apps and this was the case.
The azure-mobile-apps package was in version 2.0.0. After I updated to 2.1.0 req.body started to receive data.
Here you have the link to the Gihub issue discussion.
Thanks again for your suggestions.
GA
I had a similar use case with my custom API and fetched the parameter data via the query statement - I used a GET call, but that shouldn't make any difference here:
module.exports = {
get: function (req, res, next) {
var param = req.query.completed;
console.log(param);
}
};
The call with the attached parameter dictionary on the iOS side looked as follows:
[self.client invokeAPI:#"resetMyItems"
body:nil
HTTPMethod:#"GET"
parameters:#{#"completed": #(self.completed)}
headers:nil
completion:^(id result, NSHTTPURLResponse * _Nullable response, NSError * _Nullable error) {
if (error == nil) {
NSLog(#"Got answer from my own API: %#", result);
}
else {
NSLog(#"Something went wrong with POST api call: %#", error);
}
}
];
I searched quite a long time to find out, that the parameter you attach on your API call on the iOS side is called EXACTLY the same as on the query statement on your request.
Hope that helps :)

Seems impossible to delete a subscription in CloudKit? `-deleteSubscriptionWithID` always returns true

I'm hoping there's an experienced CloudKit guru out there, but based off my google search queries, I'm not sure if you exist. I think this may be a bug with Apple, but I can't be sure :\
I can save a subscription to my CKDatabase fine, no problems at all.
[publicDatabase saveSubscription:subscription completionHandler:^(CKSubscription *subscription, NSError *error) {
if (error)
{
//No big deal, don't do anything.
}
else
{
[[NSUserDefaults standardUserDefaults] setObject:[subscription subscriptionID] forKey:#"SUBSCRIPTION"];
}
}];
Whenever I change a field in my record, I get a push notification, and everything is happy.
My problem is removing this subscription.
I have tried calling -deleteSubscriptionWithID:completionHandler:
As you can see in the above code snippet, I save off the subscription ID (Have also confirmed it to be the correct subscription ID by calling -fetchAllSubscriptionsWithCompletionHandler:
I passed the subscriptionID in that message, like so:
[publicDatabase deleteSubscriptionWithID:[[NSUserDefaults standardUserDefaults] objectForKey:#"SUBSCRIPTION"] completionHandler:^(NSString * _Nullable subscriptionID, NSError * _Nullable error) {
if( error ) {
NSLog(#"ERROR: %#", [error description] );
}
else
{
NSLog(#"SUCCESS: %#", subscriptionID);
}
}];
But it doesn't delete my subscription:
And no matter what I pass as the subscriptionID, there is no error and I see "SUCCESS" upon "deleting".
...so yeah. Clearly that isn't going to work.
If I manually delete the subscription through the Cloudkit Dashboard, my -fetch call properly notices that and returns an empty array:
So at this point I'm certain that I'm either deleting a subscription incorrectly in code, or it's broken and (not likely) nobody has asked on SO or any other forum that I can find?
I have also tried using a CKModifySubscriptionsOperation
CKModifySubscriptionsOperation *deleteSub = [[CKModifySubscriptionsOperation alloc] initWithSubscriptionsToSave:nil subscriptionIDsToDelete:#[[[NSUserDefaults standardUserDefaults] objectForKey:#"SUBSCRIPTION"]]];
[publicDatabase addOperation:deleteSub];
No results :(
I delete subscriptions using the database.deleteSubscriptionWithID function.
If you want to make sure that the ID is correct you could also first fetch all of them using database.fetchAllSubscriptionsWithCompletionHandler({subscriptions, error in
Then in the completion handler check if it's a valid subscription using: if let subscription: CKSubscription = subscriptionObject
And then delete one or more using: database.deleteSubscriptionWithID(subscription.subscriptionID, completionHandler: {subscriptionId, error in
Here you can see code how I delete all subscriptions:
https://github.com/evermeer/EVCloudKitDao/blob/1bfa936cb46c5a2ca75f080d90a3c02e925b7e56/AppMessage/AppMessage/CloudKit/EVCloudKitDao.swift#L897-897

Kinvey iOS query all users

From Kinvey documentation this is the method to use for querying users:
To query the user collection we recommend instead using
+[KCSUserDiscovery lookupUsersForFieldsAndValues:completionBlock:progressBlock:]. This
method allows you to supply a dictionary of exact matches for special
fields.
Fields for lookup:
KCSUserAttributeUsername
KCSUserAttributeSurname
KCSUserAttributeGivenname
KCSUserAttributeEmail
KCSUserAttributeFacebookId
[KCSUserDiscovery lookupUsersForFieldsAndValues:#{ KCSUserAttributeSurname : #"Smith"}
completionBlock:^(NSArray *objectsOrNil, NSError *errorOrNil) {
if (errorOrNil == nil) {
//array of matching KCSUser objects
NSLog(#"Found %d Smiths", objectsOrNil.count);
} else {
NSLog(#"Got An error: %#", errorOrNil);
}
}
progressBlock:nil];
But if I send empty dictionary, I get an error. So what to put in dictionary to get all the users?
Thank you guys, happy holidays
To get all the users, you can use the regular app data querying API.
For example,
KCSAppdataStore* store = [KCSAppdataStore storeWithCollection:[KCSCollection userCollection] options:nil];
[store queryWithQuery:[KCSQuery query] withCompletionBlock:^(NSArray *objectsOrNil, NSError *errorOrNil) {
//handle completion
} withProgressBlock:nil];
This will get a list of all the users the active user has permission to access.

Resources