error lauchoptions undeclared IOS4? - iphone

application.applicationIconBadgeNumber = 0;
// Handle launching from a notification
UILocalNotification *localNotif =[launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (localNotif) {
NSLog(#"Recieved Notification %#",localNotif);
}
return YES;
i am getting lauchoptions undeclared my os veriosn is 4 and xcode i 3.2.3

Well, where are you getting the variable "launchOptions" from? Presumably, you're using
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
Did you rename the argument? Perhaps you need to show more of your code...

Related

localNotification issues

I am sending a local notification once a process is finished and it acts just fine.
This is my code for didReceiveLocalNotification:
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification{
CounterViewController *counterVC = [CounterViewController sharedInstance];
[counterVC notificationArrived];
}
But when the iPhone is locked those lines aren't called… What can I do to make them run in the background?
There are two method to receive local notification one is already you have implemented which is invoked while app is running & 2nd is in didFinishLaunchingWithOptions which is invoked while your app is running background you have add some code for receive local notification .....
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// Add the view controller's view to the window and display.
application.applicationIconBadgeNumber = 0;
// Handle launching from a notification
UILocalNotification *localNotif =
[launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (localNotif) {
NSLog(#"Recieved Notification %#",localNotif);
}
return YES;
}

Can't see a heatmap using Heatma.ps SDK

I successfully installed heatma.ps SDK (https://heatma.ps) in my iPhone application. It tracks all the touches and gestures, but I can't view a heatmap when I shake my device. Any idea why? There is no log, it just doesn't show up.
This is how I setup my heatmaps object.
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//...
heatmaps = [[Heatmaps alloc] init];
heatmaps.showDebug = YES;
[heatmaps start];
//...
}
To see heatmaps you need to set showMenu property of heatmaps object to YES
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//...
heatmaps = [[Heatmaps alloc] init];
heatmaps.showDebug = YES;
heatmaps.showMenu = YES;
[heatmaps start];
//...
}
Watch the following screencast: "Viewing heatmaps"

Opening in app, getting UIApplicationLaunchOptionsURLKey from launchOptions

I'm trying to open a .pdf-file in my app. I adapted the Info.plist so a .pdf can be opened in my application.
I use the following code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
thePDFurl = (NSURL *)[launchOptions valueForKey:UIApplicationLaunchOptionsURLKey];
return YES;
}
In an other class, where my appDelegate (containing that didFinishLaunchingWithOptions), I've got the line:
appDel = [[UIApplication sharedApplication]delegate];
[theLabel setText:[NSString stringWithFormat:#"%#", appDel.thePDFurl]];
Somehow, theLabel always shows (null). What am I missing?
I may be misunderstanding what you're trying to do. If so, ignore.
If you want the user to be able to "Open with..." a PDF using your app, you can implement
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
E.g.
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
NSLog(#"Open URL:\t%#\n"
"From source:\t%#\n"
"With annotation:%#",
url, sourceApplication, annotation);
NSString *filepath = [url path];
//...
return YES;
}
I'm pretty sure this works for both launching the app and calling it (i.e. if it's already in the background).
You may retain the pdfurl variable and also get the absolute string value from NSURL using the absoluteString method.
[theLabel setText:[NSString stringWithFormat:#"%#", [appDel.thePDFurl absoluteString]]]
I guess you were all right. It just so happened the view got loaded before the method applicationDidFinishLaunching was finished. Thanks all...
When you are calling within application:didFinishLaunchingWithOptions: ,
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
[viewController view] was implicitly called and there was no appDel.thePDFurl assigned yet.

Push Notifications on iPhone App

I have successfully implemented push notifications to my app. The next step is, if the user receives a notification about this certain document, he/ she clicks it and it brings them to this document.
At the moment, I can receive the notification, but it only brings me to the app.
How can I do this?
Thanks.
I am not clear with your question. But you should handle push notifications in the following methods,
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
//Handle here
}
and
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSDictionary *tmpDic = [launchOptions objectForKey:#"UIApplicationLaunchOptionsRemoteNotificationKey"];
if (tmpDic != nil) {
//Handle here also
}
}

when application become active then how we load the another view or invoke the root view controller

i have load the mailcomposer on reciving the localnotification
is it possible??
You should code as follows,
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UILocalNotification *localNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (localNotif)
{
//code for opening mail composer
}
-(void) application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
//code for opening mail composer
}