Iphone screen black on launch - ios

I am developing an iPhone app and incorporating parse. Originally, a starter project from Parse.com. This file used xib instead of storyboard; I deleted xib and made my own storyboard, and changed to Main storyboard file name base: Main_iPhone in my info.plist file. And then I dragged out a view controller and set the little arrow pointing to that view controller, but the screen is just black when the application launches. What is happening?
Here my ap delegate code:
//
// ParseStarterProjectAppDelegate.m
// ParseStarterProject
//
// Copyright 2014 Parse, Inc. All rights reserved.
//
#import <Parse/Parse.h>
// If you want to use any of the UI components, uncomment this line
// #import <ParseUI/ParseUI.h>
// If you are using Facebook, uncomment this line
// #import <ParseFacebookUtils/PFFacebookUtils.h>
// If you want to use Crash Reporting - uncomment this line
// #import <ParseCrashReporting/ParseCrashReporting.h>
#import "ParseStarterProjectAppDelegate.h"
#implementation ParseStarterProjectAppDelegate
#pragma mark - UIApplicationDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
// Instantiate the initial view controller object from the storyboard
//self.window.rootViewController = [storyboard instantiateInitialViewController];
// Enable storing and querying data from Local Datastore. Remove this line if you don't want to
// use Local Datastore features or want to use cachePolicy.
[Parse enableLocalDatastore];
// ****************************************************************************
// Uncomment this line if you want to enable Crash Reporting
// [ParseCrashReporting enable];
//
// Uncomment and fill in with your Parse credentials:
[Parse setApplicationId:#"privatecrap" clientKey:#"privatecrap"];
//
// If you are using Facebook, uncomment and add your FacebookAppID to your bundle's plist as
// described here: https://developers.facebook.com/docs/getting-started/facebook-sdk-for-ios/
// [PFFacebookUtils initializeFacebook];
// ****************************************************************************
[PFUser enableAutomaticUser];
PFACL *defaultACL = [PFACL ACL];
// If you would like all objects to be private by default, remove this line.
[defaultACL setPublicReadAccess:YES];
[PFACL setDefaultACL:defaultACL withAccessForCurrentUser:YES];
// Override point for customization after application launch.
//self.window.rootViewController = self.viewController;
//[self.window makeKeyAndVisible];
if (application.applicationState != UIApplicationStateBackground) {
// Track an app open here if we launch with a push, unless
// "content_available" was used to trigger a background push (introduced in iOS 7).
// In that case, we skip tracking here to avoid double counting the app-open.
BOOL preBackgroundPush = ![application respondsToSelector:#selector(backgroundRefreshStatus)];
BOOL oldPushHandlerOnly = ![self respondsToSelector:#selector(application:didReceiveRemoteNotification:fetchCompletionHandler:)];
BOOL noPushPayload = ![launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
if (preBackgroundPush || oldPushHandlerOnly || noPushPayload) {
[PFAnalytics trackAppOpenedWithLaunchOptions:launchOptions];
}
}
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000
if ([application respondsToSelector:#selector(registerUserNotificationSettings:)]) {
UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert |
UIUserNotificationTypeBadge |
UIUserNotificationTypeSound);
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes
categories:nil];
[application registerUserNotificationSettings:settings];
[application registerForRemoteNotifications];
} else
#endif
{
[application registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeAlert |
UIRemoteNotificationTypeSound)];
}
// self.window.rootViewController=[[UIStoryboard storyboardWithName:#"Main" bundle:nil] instantiateViewControllerWithIdentifier:#"emailStoryboard"];
return YES;
}
/*
///////////////////////////////////////////////////////////
// Uncomment this method if you are using Facebook
///////////////////////////////////////////////////////////
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
return [PFFacebookUtils handleOpenURL:url];
}
*/
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)newDeviceToken {
[PFPush storeDeviceToken:newDeviceToken];
[PFPush subscribeToChannelInBackground:#"" target:self selector:#selector(subscribeFinished:error:)];
}
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
if (error.code == 3010) {
NSLog(#"Push notifications are not supported in the iOS Simulator.");
} else {
// show some alert or otherwise handle the failure to register.
NSLog(#"application:didFailToRegisterForRemoteNotificationsWithError: %#", error);
}
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
[PFPush handlePush:userInfo];
if (application.applicationState == UIApplicationStateInactive) {
[PFAnalytics trackAppOpenedWithRemoteNotificationPayload:userInfo];
}
}
///////////////////////////////////////////////////////////
// Uncomment this method if you want to use Push Notifications with Background App Refresh
///////////////////////////////////////////////////////////
/*
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
if (application.applicationState == UIApplicationStateInactive) {
[PFAnalytics trackAppOpenedWithRemoteNotificationPayload:userInfo];
}
}
*/
- (void)applicationWillResignActive:(UIApplication *)application {
/*
Sent when the application is about to move from active to inactive state.
This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message)
or when the user quits the application and it begins the transition to the background state.
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates.
Games should use this method to pause the game.
*/
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
/*
Use this method to release shared resources, save user data, invalidate timers, and store enough application state
information to restore your application to its current state in case it is terminated later.
If your application supports background execution,
this method is called instead of applicationWillTerminate: when the user quits.
*/
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
/*
Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
*/
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
/*
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
*/
}
- (void)applicationWillTerminate:(UIApplication *)application {
/*
Called when the application is about to terminate.
Save data if appropriate.
See also applicationDidEnterBackground:.
*/
}
#pragma mark - ()
- (void)subscribeFinished:(NSNumber *)result error:(NSError *)error {
if ([result boolValue]) {
NSLog(#"ParseStarterProject successfully subscribed to push notifications on the broadcast channel.");
} else {
NSLog(#"ParseStarterProject failed to subscribe to push notifications on the broadcast channel.");
}
}
#end

If you click on your project in the file explorer on the left side, under general does "Main interface" contain the name of your storyboard?
Also you have said (I think), that your storyboard is call Main_iPhone, however your code is calling Main and then doing nothing with the storyboard or checking if its nil etc.
You either need to set the main interface in the target, or instantiate the initial viewController inside didFinishLaunchingWithOptions and set it as the rootViewController of the window. e.g.
self.window.rootViewController=[[UIStoryboard storyboardWithName:#"Main_iPhone" bundle:nil] instantiateInitialViewController];
you don't need to do both, only one or the other.

Related

Xcode 6.3 Parse error 'could not build module 'Parse'

This is a repeat I believe of unanswered question here:
https://stackoverflow.com/questions/34499353/could-not-build-module-parse-xcode-6-1-1
I have attempted uninstall and reinstall the sdks, remove and reinsert the framework, and reinstalled the framework and sdk into a brand new project, and is giving error message Every time I try to add reference in AppDelegate.m by adding #import it says couldn't build module 'Parse'.Here are the steps I have followed : https://parse.com/apps/quickstart#parse_data/mobile/ios/native/existing.
Please help me to understand where I went wrong, any feedback would be highly appreciated.
AppDelegate.m
#import "AppDelegate.h"
#import <Parse/Parse.h>
#implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
// [Optional] Power your app with Local Datastore. For more info, go to
// https://parse.com/docs/ios/guide#local-datastore
[Parse enableLocalDatastore];
// Initialize Parse.
[Parse setApplicationId:#"Removed for security purposes"
clientKey:#"Removed for security purposes"];
// [Optional] Track statistics around application opens.
[PFAnalytics trackAppOpenedWithLaunchOptions:launchOptions];
// Register for Push Notitications
UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert |
UIUserNotificationTypeBadge |
UIUserNotificationTypeSound);
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes
categories:nil];
[application registerUserNotificationSettings:settings];
[application registerForRemoteNotifications];
//Starting the ROXIMITY Engine!
[ROXIMITYEngine startWithLaunchOptions:launchOptions engineOptions:nil applicationId:#"Removed for security purposes" andEngineDelegate:self];
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
[ROXIMITYEngine resignActive]; // Place in applicationWillResignActive
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
[ROXIMITYEngine background]; // Place in applicationDidEnterBackground
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
[ROXIMITYEngine foreground]; // Place in applicationWillEnterForeground
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
[ROXIMITYEngine active]; // Place in applicationDidBecomeActive
}
- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
[ROXIMITYEngine terminate]; // Place in applicationWillTerminate
}
//Adding the following methods for remote notification handling
-(void) application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
[ROXIMITYEngine didFailToRegisterForRemoteNotifications:error];
}
-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
[ROXIMITYEngine didRegisterForRemoteNotifications:deviceToken];
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
[currentInstallation setDeviceTokenFromData:deviceToken];
currentInstallation.channels = #[#"global"];
[currentInstallation saveInBackground];}
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{
[ROXIMITYEngine didReceiveRemoteNotification:application userInfo:userInfo];
[PFPush handlePush:userInfo];
if (application.applicationState == UIApplicationStateInactive) {
[PFAnalytics trackAppOpenedWithRemoteNotificationPayload:userInfo];
}
}
-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification{
[ROXIMITYEngine didReceiveLocalNotification:application notification:(UILocalNotification *)notification];
}
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler{
[ROXIMITYEngine didReceiveRemoteNotification:application userInfo:userInfo fetchCompletionHandler:completionHandler];
if (application.applicationState == UIApplicationStateInactive) {
[PFAnalytics trackAppOpenedWithRemoteNotificationPayload:userInfo];}
}
#end
AppDelegate.h
#import <UIKit/UIKit.h>
#import "ROXIMITYSDK.h"
#interface AppDelegate: UIResponder <UIApplicationDelegate, ROXIMITYEngineDelegate>
#property (strong, nonatomic) UIWindow *window;
#end
I ran into this problem as well when trying to integrate the SDK manually. I solved it by using cocoapods to handle integrating Parse.

How to clear my notification badge

I have a app to which i can send push notifications using pushbots. The user is able to receive the notification and on clicking it he/she can open the app. However the badge notification still shows that there is a notification. How would i set my notification badge to 0.
This is my appdelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Register for Remote Notifications
[Pushbots sharedInstanceWithAppId:#"5503e09a1d0ab1481f8b45a1"];
NSDictionary * userInfo = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
if(userInfo) {
// Notification Message
NSString* notificationMsg = [userInfo valueForKey:#"alert"];
// Custom Field
NSString* title = [userInfo valueForKey:#"title"];
NSLog(#"Notification Msg is %# and Custom field title = %#", notificationMsg , title);
}
return YES;
}
-(void)onReceivePushNotification:(NSDictionary *) pushDict andPayload:(NSDictionary *)payload {
NSString* message = [pushDict valueForKey:#"alert"];
UIAlertView *alertMessage = [[UIAlertView alloc] initWithTitle:#"New Event !" message:message delegate:self cancelButtonTitle:#"Open" otherButtonTitles: #"I will check later",nil];
[alertMessage show];
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
Pushbots * pushbots = [Pushbots sharedInstance];
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
if([title isEqualToString:#"Open"]) {
[pushbots OpenedNotification];
}
}
- (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
#end
You can call this in your application :
[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
Obviously this needs a little more work. If you're dealing with messages for example, you'd need to decrement the badge number by the number of messages read and make sure to not go below zero.
You can also use the "badge" key to modify the current badge through the notification payload itself.
for example use
{..., "badge" : "increment", ...}
or
{...,"badge" : 3, ...}
The first one would be the most frequent version i'm guessing.
But if your app is fairly simple, then just call this and your badge will be set to zero.
I'd advise you to update your pushbots lib to 1.1 and use the following method which will clear the badge locally and on the server:
[[Pushbots sharedInstance] clearBadgeCount];
For Swift 3
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool
{
UIApplication.sharedApplication().applicationIconBadgeNumber = 0
Pushbots.sharedInstance().clearBadgeCount()
}
func applicationWillEnterForeground(application: UIApplication)
{
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
UIApplication.sharedApplication().applicationIconBadgeNumber = 0
Pushbots.sharedInstance().clearBadgeCount()
}
Objective C
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
[[Pushbots sharedInstance] clearBadgeCount];
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
[[Pushbots sharedInstance] clearBadgeCount];
}

Parse - How to stop modal alert while app opening(foreground), when received remote notification IOS?

I have a problem during I developing application IOS and I used Parse Push Notification Framework for push remote notification. the problem is when the application is running and the same time the notification has been sent, the application is display modal alert box automatically. So, I don't want the modal alert display. I spent much times on it, and I do research on internet, read documents but no result found, I feel nobody knew about this. Please Help me!
AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
UIImage *navBackgroundImage = [UIImage imageNamed:#"nav_bg_new"];
[[UINavigationBar appearance] setBackgroundImage:navBackgroundImage forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setTitleTextAttributes:#{NSForegroundColorAttributeName : [UIColor whiteColor]}];
// ****************************************************************************
// Uncomment and fill in with your Parse credentials:
// [Parse setApplicationId:#"your_application_id" clientKey:#"your_client_key"];
// ****************************************************************************
[Parse setApplicationId:#"my_app_id" clientKey:#"my_client_key"];
// Override point for customization after application launch.
[application registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeSound];
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
[currentInstallation setDeviceTokenFromData:deviceToken];
currentInstallation.channels = #[#"global"];
[currentInstallation saveInBackground];
}
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
if (error.code == 3010) {
NSLog(#"Push notifications are not supported in the iOS Simulator.");
} else {
// show some alert or otherwise handle the failure to register. NSLog(#"application:didFailToRegisterForRemoteNotificationsWithError: %#", error);
}
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
[PFPush handlePush:userInfo];
}
Thanks so much in advance.
If you only want to make sure you DO NOT see notifications when the app is opening, set a BOOL isOpening to TRUE in your application:willFinishLaunchingWithOptions: and set it to FALSE during application:didFinishingLaunchingWithOptions:, then change the behavior of didReceiveRemoteNotification: and the call to PFPush handlePush: accordingly.
You can try this instead:
#property (nonatomic, assign) BOOL isLaunching;
- (void)applicationWillEnterForeground:(UIApplication *)application
{
isLaunching = TRUE;
}
- (void)applicationDidEnterForeground:(UIApplication *)application
{
isLaunching = FALSE;
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
if (!isLaunching) {
//Only fire the push handler if the application isn't active
[PFPush handlePush:userInfo];
}
}

Connecting Parse with FB integration

I'm creating a chat app, and the user is first taken to the main menu, where they can select "chat" and then be directed to a FB Login feature, after the user logs in with FB, they are supposed to be redirected to a tab bar controller. However I cannot figure out how to set the programatic segue up so that it takes the user directly to that screen after a successful login.
I don't know if that's why Parse isn't collecting the User Data or not, but I get this warning when running the app: [10799:60b] Warning: A long-running Parse operation is being executed on the main thread. Break on warnParseOperationOnMainThread() to debug. My question is how do I create that segue to my Tab Bar Controller and am I missing something with Parse?
Here is my AppDelegate.m file:
#import "CCAppDelegate.h"
#import <Parse/Parse.h>
#implementation CCAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
[Parse setApplicationId:#"XXXX"
clientKey:#"XXXX"];
[PFAnalytics trackAppOpenedWithLaunchOptions:launchOptions];
[PFFacebookUtils initializeFacebook];
[FBLoginView class];
[FBProfilePictureView class];
return YES;
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
BOOL wasHandled = [FBAppCall handleOpenURL:url sourceApplication:sourceApplication];
return wasHandled;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
#end
And here is my CCLoginViewController.m file:
#import "CCLoginViewController.h"
#interface CCLoginViewController ()
#property (strong, nonatomic) IBOutlet UIActivityIndicatorView *activityIndicator;
#end
#implementation CCLoginViewController
-(void)toggleHiddenState:(BOOL)shouldHide
{
self.lblUsername.hidden = shouldHide;
self.lblEmail.hidden = shouldHide;
self.profilePictureView.hidden = shouldHide;
}
-(void)loginViewShowingLoggedInUser:(FBLoginView *)loginView{
self.lblLoginStatus.text = #"You are logged in.";
[self toggleHiddenState:NO];
}
-(void)loginViewFetchedUserInfo:(FBLoginView *)loginView user:(id<FBGraphUser>)user{
NSLog(#"%#", user);
self.profilePictureView.profileID = user.objectID;
self.lblUsername.text = user.name;
self.lblEmail.text = [user objectForKey:#"email"];
}
-(void)loginViewShowingLoggedOutUser:(FBLoginView *)loginView{
self.lblLoginStatus.text = #"You are logged out";
[self toggleHiddenState:YES];
}
-(void)loginView:(FBLoginView *)loginView handleError:(NSError *)error{
NSLog(#"%#", [error localizedDescription]);
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
self.loginView.delegate = self;
[super viewDidLoad];
// Do any additional setup after loading the view.
[self toggleHiddenState:YES];
self.lblLoginStatus.text = #"";
self.lblLoginStatus.text = #"";
self.loginView.readPermissions = #[#"public_profile", #"email"];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
#end
According to the docs on iOS, Facebook Users you should be calling FBAppCall slightly differently:
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
return [FBAppCall handleOpenURL:url
sourceApplication:sourceApplication
withSession:[PFFacebookUtils session]];
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
[FBAppCall handleDidBecomeActiveWithSession:[PFFacebookUtils session]];
}
The key part you're missing is the withSession:[PFFacebookUtils session], which I'm guessing lets Parse know about what Facebook is doing.
I also don't see any Parse query in your code, so some other part of your code must be triggering that warning, somewhere you're doing a query without using a withBlock:, which lets it handle the results on a background thread without locking up the UI.

Check application lifecycle's status

#import "AppDelegate.h"
#implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
#end
I want to check when this all method calls.
How can I put NSLog to every method so whenever it gets called I know?
copy & paste ?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSLog(#"didFinishLaunchingWithOptions");
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
NSLog(#"applicationWillResignActive");
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
NSLog(#"applicationDidEnterBackground");
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
NSLog(#"applicationWillEnterForeground");
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
NSLog(#"applicationDidBecomeActive");
}
- (void)applicationWillTerminate:(UIApplication *)application
{
NSLog(#"applicationWillTerminate");
}
#end

Resources