Objective-C Firebase reloadWithCompletion not executing completion code - objective-c

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.

Related

location manager working on Always but not When In Use

I have an app that worked great before Apple insisted users be given a choice between "Always" and "When In Use" for Location Manager.
The app used iBeacons to send invitations to play games and accept.
When "Always" is selected the beacons work fine but when I switch to "When In Use" they don't work at all.
I started out using "Always" but change the following code to give users the choice.
In the app's plist I added "Privacy-Location Always and When In Use Usage Descriptions and Privacy-Location When In Use Usage Description" and removed the "Privacy-Location Always Usage Description".
In the app's Delegate I have this
- (void)locationManager:(CLLocationManager *)manager
didChangeAuthorizationStatus:(CLAuthorizationStatus)status{
if([CLLocationManager authorizationStatus]==kCLAuthorizationStatusAuthorizedAlways){
NSLog(#"Always");
AlertView2 = [[UIAlertView alloc] initWithTitle:#"Dual player on two devices is enabled."
message:#"To save battery power go to Settings/Privacy/Location Services and choose \"Never\" when not using I'M GAME. Two people can still play on one device when in \"Never\" mode. To recieve invitations to play only when the app is open select \"When In Use\"."
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[AlertView2 show];
[[NSUserDefaults standardUserDefaults] setObject:#"YES" forKey:#"accessKey"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
if([CLLocationManager authorizationStatus]==kCLAuthorizationStatusAuthorizedWhenInUse){
NSLog(#"WhenInUse");
AlertView2 = [[UIAlertView alloc] initWithTitle:#"Dual player on two devices is enabled."
message:#"To save battery power go to Settings/Privacy/Location Services and choose \"Never\" when not using I'M GAME. Two people can still play on one device when in \"Never\" mode. To recieve invitations to play while app is in background select \"Always\"."
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[AlertView2 show];
[[NSUserDefaults standardUserDefaults] setObject:#"YES" forKey:#"accessKey"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
if([CLLocationManager authorizationStatus]==kCLAuthorizationStatusRestricted){
NSLog(#"restricted");
}
if([CLLocationManager authorizationStatus]==kCLAuthorizationStatusDenied){
NSLog(#"denied");
AlertView2 = [[UIAlertView alloc] initWithTitle:#"Dual player on a single device Only."
message:#"To play on two devices go to Settings Privacy/Location Services and choose \"Always\" or \"When In Use\" for I'M GAME. In \"Always\" you can recieve invites while app is in background, in \"When In Use\" invites only appear when the app is on screen. To preserve battery choose \"Never\" when not using I'M GAME."
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[AlertView2 show];
[[NSUserDefaults standardUserDefaults] setObject:#"YES" forKey:#"accessKey"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
if([CLLocationManager authorizationStatus]==kCLAuthorizationStatusNotDetermined){
NSLog(#"undetermined2");
[locationManager requestAlwaysAuthorization];
[locationManager requestWhenInUseAuthorization];
}
}
Does iBeacon need to have Privacy-Location set to "Always" to work?
So I just found out that in "When In Use" you can't monitor for beacon region is entered or exited only find its range. So I guess the question is how would I use range to send a notification to my user.
When you have your app authorized to do beacon ranging only when it is in the foreground, it's easy to simulate entry/exit logic with just a didRangeBeacons callback.
Set up one class variable:
var beaconLastSeen: Date? = nil
Add this code to your didRangeBeacons method:
if beacons.count > 0 {
if beaconLastSeen == nil {
// call didEnterRegion logic here
}
beaconLastSeen = Date()
}
else {
if beconLastSeen != nil && Date() - beaconLastSeen > 30 {
beaconLastSeen = nil
// call didExitRegion logic here
}
}
You will get an exit event 30 secs after the last beacon detection. You will get an enter event when one is first seen.
EDIT: Here's the same code in Objective C:
NSDate *beaconLastSeen = nil;
...
if (beacons.count > 0) {
if (beaconLastSeen == nil) {
// call didEnterRegion logic here
}
beaconLastSeen = [[NSDate alloc] init];
}
else {
if (beaconLastSeen != nil && [[[NSDate alloc] init] timeIntervalSinceDate: beaconLastSeen] > 30 ) {
beaconLastSeen = nil;
// call didExitRegion logic here
}
}

Get list of online users PubNub always nil 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.

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

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"
}
]
}
}

Missing sentinel in UIAlertView allocation

UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:#"Error"
message:#"Some failure message"
delegate:self
cancelButtonTitle:#"cancel"
otherButtonTitles:#"retry", nil
];
[alert show];
[alert release];
I got two warnings pointing at this block of code.
Unused variable 'alert'
Missing sentinel in function call
My code looks similar to all the examples online. Why is it broken?
This code works fine for me. Try cleaning all targets and building again to see if the error persists.
Because you call [alert show], you should not get an unused variable warning on alert.
Since you include nil after otherButtonTitles, you should not get a missing sentinel warning.