Get list of online users PubNub always nil Objective C - objective-c

My question is same of User list for pubnub-chat objective c but it seem has no helpful answers.
I registed client with Pub & Sub key with Presence = YES
I subsrcibed to "My channel" and could send msg to it
I used debug console in PubNub admin to create 2 others clients, I could send msg together
I enable Presence in Admin (http://prntscr.com/iyv7b1)
I get list user that subscribe "My channel" by function:
[client hereNowForChannel:#"My channel" withVerbosity:PNHereNowState completion:^(PNPresenceChannelHereNowResult *result, PNErrorStatus *status)
{
if (!status) {
}
else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error" message:#"Couldn't get list of user." delegate:nil cancelButtonTitle:#"Close" otherButtonTitles:nil];
[alert show];
}
}];
I tried to change
PNHereNowState -> PNHereNowUUID -> PNHereNowOccupancy
But my result is always NIL.
Anybode help me, pls

I found the answer for my question, hope it helps for who need
[client hereNowForChannel:client.globalChannel withCompletion:^(PNPresenceChannelHereNowResult *result, PNErrorStatus *status)
{
if (!status) {
PNPresenceChannelHereNowData *data = result.data;
if (data) {
NSArray *list = [data uuids];
}
}
else {
}
}];
The property data, it won't be set value if has no access to it yet, so I did call PNPresenceChannelHereNowData *data = result.data; and it had data.

Related

Objective-C Firebase reloadWithCompletion not executing completion code

My code is not executing the completion callback after calling reloadWithCompletion
if ([FIRAuth auth].currentUser.isEmailVerified) {
_emailField.text = [FIRAuth auth].currentUser.email;
} else {
[[FIRAuth auth].currentUser reloadWithCompletion:^(NSError * _Nullable error) {
if ([FIRAuth auth].currentUser.isEmailVerified) {
_emailField.text = [FIRAuth auth].currentUser.email;
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Email Validation"
message:#"Your email must be validated to continue."
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[alert show];
}
}];
}
Any help is appreciated.
As it turns out I fixed the problem but I still don't know why or how the completion code was not working for this user. I simply used the Firebase Authentication console to delete the user record. My app then re-created the record and now the completion code executes properly.

Error Sending twilio SMS via parse

I'm trying to send a text message via Twilio and parse, but the cloud function produces "uh oh something went wrong." why?
Here's the xcode code:
//Sends SMS via Parse Cloud code to a number....//TODO test, debug...
+(void)sendSMSWithVerificationCode:(NSString *)verificationString toNumberString:(NSString *)phoneNumber {
NSMutableString * message=[[NSMutableString alloc] initWithString:#"Brighten verification code: "];
[message appendString:verificationString];
// Call our Cloud Function that sends an SMS with Twilio
[PFCloud callFunctionInBackground:#"sendSMSVerification"
withParameters:#{ #"number" : phoneNumber , #"messageString" : message}
block:^(id object, NSError *error) {
[[[UIAlertView alloc] initWithTitle:#"Verification code sent!"
message:nil
delegate:nil
cancelButtonTitle:#"Ok"
otherButtonTitles:nil, nil] show];
}];
}
and the cloud function looks as follows:
twilio.initialize("meh",",mehh"); //these are for testing; todo insert real ones when deploying
// Create the Cloud Function
Parse.Cloud.define("sendSMSVerification", function(request, response) {
// Use the Twilio Cloud Module to send an SMS
twilio.sendSMS({
From: "111111111111111(my number as a string)",
To: request.params.number,
Body: request.params.message //SMS Verification: 1234 or whatever the specific number is...
}, {
success: function(httpResponse) { response.success("SMS sent!"); },
error: function(httpResponse) { response.error("Uh oh, something went wrong"); }
});
});

Can't retrieve EKCalendars from EKEventStore in iOS7

I've recently found out, that I do not receive any EKCalendar objects from EKEventStore in iOS7. In iOS 6.x.x there are no problems with same code snippet. When I'm trying to access defaultCalendarForNewEvents - I do receive a single EKCalendar object (as expected).
I do request access to entity type EKEntityTypeEvent.
The snippet:
__block NSMutableArray *calendarsArray = nil;
if ([self.eventsStore respondsToSelector:#selector(requestAccessToEntityType:completion:)]) {
[self.eventsStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
if (granted) {
EKAuthorizationStatus status = [EKEventStore authorizationStatusForEntityType:EKEntityTypeEvent];
if (status == EKAuthorizationStatusAuthorized) {
calendarsArray = [[NSMutableArray alloc] initWithArray:[self.eventsStore calendarsForEntityType:EKEntityMaskEvent]];
}
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error!" message:#"You haven't granted access to calendars. Expected things are not going to happen." delegate:nil cancelButtonTitle:#"I understand" otherButtonTitles:nil];
[alert show];
}
}];
} else {
calendarsArray = [NSMutableArray arrayWithArray:[self.eventsStore calendarsForEntityType:EKEntityTypeEvent]];
}
I do receive 0 objects into calendarsArray. I've also tried to get it by "running through" all EKSources that are of type Local or CalDAV ([source calendarsForEntityType:] - got the same empty (0 object containing) set).
By the way - access to calendars IS granted.
Any suggestions?
After a brief investigation I have found out, that the problem was not in the code. It appears that the problem is in iOS 7.0.3 itself.
After deleting all the sync'ed calendars from the iDevice and adding it back all of the calendars were displayed both within the native Calendar application, and the one I made. After taking this action my code was able to retrieve the calendars from EventStore not depending on the method I would access calendars (via EKSources or EKEventStore itself).

Filter the friend returned by FBFriendPickerViewController in new Facebook 3.0

I have an Facebook app on http://developer.facebook.com of type "Native iOS" which is connected to the actual iOS app using the new Facebook iOS SDK 3.0.
How can I know if the multiple people that already install the the app and authorize the Facebook app too so I can put them in some list, but this not my question because I know that there is a field called "installed" that return true when the user install the app.
So if I want to filter the returned friend by the FBFriendPickerViewController based on if the user use the app, so how I can use the installed field or something else to filter the friends.
Note: I know where to filter the friend (*) all I need is the field or the property that I need to check to make sure the user is install my app.
*- (BOOL)friendPickerViewController:(FBFriendPickerViewController *)friendPicker
shouldIncludeUser:(id<FBGraphUser>)user
I found a way to do this :
I create a method that send an FQL to those I need (for example my friends that they are male)
and then compare those returned by this request with the already exists by the FBFriendPickerViewController using the method :
- (BOOL)friendPickerViewController:(FBFriendPickerViewController *)friendPicker shouldIncludeUser:(id<FBGraphUser>)user
for the request :
NSDictionary *queryParam = [NSDictionary dictionaryWithObjectsAndKeys:#"query", #"q", nil];
[FBRequestConnection startWithGraphPath:#"/fql" parameters:queryParam HTTPMethod:#"GET"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (error)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Oops" message:#"Some thing go wrong !, Try again" delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil, nil];
[alert show];
}
else
{
NSArray *friendInfo = (NSArray *) [result objectForKey:#"data"];
for(int i = 0; i < [friendInfo count]; i++)
{
[self.friendsNames addObject:[[friendInfo objectAtIndex:i] objectForKey:#"name"]];
}
}
}];
As you see I have an NSArray that store the filtered friend, the next step is to compare them in the delegate method above.
Hope you find it useful.

How to change video from private to public YouTube API with Gdata for iOS App

I have an iOS app that gets all the videos from a user through gdata and YouTube API. My problem comes with private videos, I need to make it so that it makes a private video public when the video is selected.
For some reason whenever I try to make the video public, I cannot edit it because the editLink of an entry returned by YouTube API is empty.
Here's my code someone can tell me what I'm doing wrong or what I can do to make the change:
GDataEntryBase *entry = [[feed entries] objectAtIndex:selectedRow];
[[(GDataEntryYouTubeVideo *)entry mediaGroup] setIsPrivate:NO];
//GDataEntryYouTubeUpload *uploadEntry =
//[GDataEntryYouTubeUpload uploadEntryWithMediaGroup:mediaGroup
//fileHandle:nil MIMEType:#"video/mp4" slug:[[entry title]
//stringValue]];
GDataServiceTicket *ticket;
GDataServiceGoogleYouTube *service = [self youTubeService];
NSString *str = [entry canEdit] ? #"YES" : #"NO";
NSLog(#"Can edit %#", str);
NSLog(#"Edit URL %#", [[entry editLink] URL] );
// NSURL *url = [GDataServiceGoogleYouTube
//youTubeUploadURLForUserID:kGDataServiceDefaultUser];
ticket = [service fetchEntryByUpdatingEntry:entry
forEntryURL:[[entry editLink] URL] delegate:self
didFinishSelector:#selector(uploadTicket:finishedWithEntry:error:)];
// ticket = [service fetchEntryByUpdatingEntry:entry
//delegate:self didFinishSelector:#selector(uploadTicket:finishedWithEntry:error:)];
NSLog(#"Ticket = %#", ticket);
}
}
- (void)uploadTicket:(GDataServiceTicket *)ticket
finishedWithEntry:(GDataEntryYouTubeVideo *)videoEntry error:(NSError
*)error {
NSLog(#"Finished...");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Upload
failed" message:[NSString stringWithFormat:#"Upload failed: %#",
error] delegate:self cancelButtonTitle:#"Cancel"
otherButtonTitles:nil, nil];
if (error != nil) {
NSLog(#"Errors: %#", error);
[alert show];
} else {
NSLog(#"NO ERRORS :))");
}
}
I included developer key in the request/response shown below and received the editLink in the response. You will have to relate the protocol using the oauth playground to your client-side language.
https://groups.google.com/group/youtube-api-gdata/browse_thread/thread/346eb7c8bdd6c3ae
Did you authenticate your requests?
Did you specify v=2?
Did you include the developer key in the query?
If your authenticated and using v=2 in the query string then you should get the edit link.
Learn the dev tools at https://code.google.com/oauthplayground/ where i made the following request specifying partial gdata fields that would contain just the link[#rel="edit"] tag :
GET /feeds/api/users/default/uploads/7dtC4kS3x08?v=2&fields=link%5B%40rel%3D%22edit%22%5D&alt=json&key=${YT-devKeyValue} HTTP/1.1
Host: gdata.youtube.com
Authorization: OAuth ya29.AHES6ZSqIlhsyFfbzZ7x-PTVR1JiTj1PjPvBbfq7RtKnaJk
Response includes editlink at the bottom - you should use the value of the attribute=href when you POST your update to the api:
{
"version":"1.0",
"encoding":"UTF-8",
"entry":{
"xmlns":"http://www.w3.org/2005/Atom",
"xmlns$yt":"http://gdata.youtube.com/schemas/2007",
"link":[
{
"rel":"edit",
"type":"application/atom+xml",
"href":"https://gdata.youtube.com/feeds/api/users/rowntreerob/uploads/7dtC4kS3x08?v=2"
}
]
}
}