How to run local notification using revmob - iphone

Revmob is working fine in my app,but i want to send local notification using revmob
[[RevMobAds session] scheduleLocalNotification];
// in your AppDelegate.m
(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
[[RevMobAds session] processLocalNotification:notification];
}
This is the code i am using,but after that it is not running,there is something wrong with my code,i guess,please help

As described in the RevMob site, the scheduleLocalNotification method scheduled a notifications at a time which RevMob expects to be the best. Yesterday this time was around 5:30pm (local time), but they can change it if they think is necessary.
If you want to test the local notification in a specific time you can use the scheduleLocalNotification: method.

Related

Stop setKeepAliveTimeout handler from being called after application came foreground?

For VOIP application we are sending PING packet to server every 10 minutes using setKeepAliveTimeout, everything works fine, however I'm not sure how to stop the handler from being called once application came foreground.
eg: Here is how I set the timeout
[[UIApplication sharedApplication] setKeepAliveTimeout:600 handler:^{ [self backgroundHandler]; }];
Background handler:
- (void)backgroundHandler
{
printf("10 minute time elapsed\n");
// do some action...
}
Above function is being called even after application came foreground, I have read in Apple documentation to set the handler nil to stop it. I have tried like below in applicationWillEnterForeground
[UIApplication sharedApplication] setKeepAliveTimeout:600 handler:nil];
Still I'm getting call every 10 mins. How to handle this, Do I need to use flag only.
Any help is really appreciated.
you can do it like this
- (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.
[[UIApplication sharedApplication] clearKeepAliveTimeout];
}
You have to invoke clearKeepAliveTimeout to stop the timer. setKeepAliveTimeout: is designed to keep a voip connection on and that's why it's periodically called.

local notification handling

I am trying to crack the way local notification work.
I wrote this line in order to present the notification I scheduled:
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification{
[[UIApplication sharedApplication] presentLocalNotificationNow:notification];
}
The issue is that it runs endless number of times.
If I write something else it runs only one time, but i understood that this line should pop up the message of the notification.
Can anyone shed some light?
Thanks,
presentLocalNotificationNow is triggering didReceiveLocalNotification which in turn is calling presentLocalNotificationNow... so you end up with an endless loop.
Found it,
I didn't realize that by reaching the didReceiveLocation method it automatically sends a notification message if the iPhone is not activated.
No need to write anything...

Clear push notification badge after increment

I am working on push notification in iphone. when i receive push notification, its showing 1 on my application icon, next time its 2,3,4. if i open application its 0. Next time its should be 1,2,3,4... but its showing last number and +1. i want reset push notification badge after open application. i am sending +1 from urban airship.
and its not working for me.
[[UIApplication sharedApplication] cancelAllLocalNotifications];
[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
I use this code in my app because the Urban Airship (UA) documentation said to
[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
[[UAPush shared] resetBadge];
but it doesn't work, the badge on the app icon keeps incrementing. I saw a few posts on this very issue on UA's forums and they haven't given a clear answer.
EDIT #1:
I received the following response from a support technician at UA with the following suggestions, which worked great:
What you want to do, is ensure that in your didFinishLaunchingWithOptions:(NSDictionary *)launchOptions method, you are calling the following:
[[UAPush shared] setAutobadgeEnabled:YES];
[[UAPush shared] resetBadge];//zero badge on startup
and also call [[UAPush shared] resetBadge]; in the following methods as well:
applicationDidBecomeActive:(UIApplication *)application
and
didReceiveRemoteNotification:(NSDictionary *)userInfo
The technician also mentioned that assigning 0 to applicationIconBadgeNumber is not necessary, so I took it out. Still works beautifully.
EDIT #2:
I ended up having to modify application:didReceiveRemoteNotification: to include a call to UA's handleNotification:applicationState: method:
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
// Get application state for iOS4.x+ devices, otherwise assume active
UIApplicationState appState = UIApplicationStateActive;
if ([application respondsToSelector:#selector(applicationState)])
{
appState = application.applicationState;
}
[[UAPush shared] handleNotification:userInfo applicationState:appState];
[[UAPush shared] resetBadge];
}
because I was having a problem with the following scenario:
User is in app
Push notification received
No badge was displayed on app icon when returning to home screen (as expected)
Another push notification is received
Badge displayed number greater than 1
With the modification above, this scenario is handled. I guess you have to tell UA that the notification is handled when one is received and the app is running in the foreground.
I have used Urban Airship and have had this problem before. You are not showing the code but i am assuming that when a notification is received, you are setting the application badge number to what urban airship is passing to you, don't do that. Just let the application self handle this, when a remote notification comes in, let it auto increment on its own. If that is not the case it could be that, on the urban airship side, you are setting a badge number to send with the push. Do not send a badge number with the push notification, leave that part out, iOS should auto increment your badge from its current badge number.

badge number count increament

I have implemented the local notification concept, it is working properly but there is a problem in badge number it is not increamenting automatically as notifications occurs. I have got a link where solution for this problem is given but don't know how to use it in app delegate. Following is the link... If someone know how to auto increament the badge number ,please provide me some solution.
https://github.com/csheldrick/UILocalNotification
Thanku very much.
When you create your local notification then before registring it with the system add this line of code.
localNotif.applicationIconBadgeNumber = [UIApplication sharedApplication].applicationIconBadgeNumber+ 1;
and then you register you notification with the system
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
localNotif is object of UILocalNotification
Hope this helps
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
[UIApplication sharedApplication].applicationIconBadgeNumber=application.applicationIconBadgeNumber+1;
}
i hope it will help ful to you

Problem With PushNotification if you select No at the first time

As i said in the title of this thread, I have a problem with Push notification of my application.
There is 2 cases :
When the app asks you if you want push notification and you push OK, it's working great.
This function :
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken
is called when registerForRemoteNotificationTypes is called :
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Add registration for remote notifications
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)];
...
}
But when you select NO at the beginning, and then you change your settings to accept push notification, nothing append and this function didRegisterForRemoteNotificationsWithDeviceToken is never called.
Please help me, i'm getting crazy!
I see you register for remote notifications in:
- (void)applicationDidFinishLaunching:(UIApplication *)application
If your application is running on a iOS device with support for multitasking that might not be the right place.
The above method is called when you initially launch your app from cold. This is when you are prompted to accept or decline Push Notifications - and in your case decline.
When you later exit the application to change the settings in the device wide control panel the application is not quit - it is merely resigning as the foreground application. When you have enabled Push Notifications in the control panel and return to your application - the application is not launched again but moves from being backgrounded to the foreground.
Your application delegate will at this point receive an:
- (void) applicationDidBecomeActive:(UIApplication *)application
try registering for Push Notifications there instead using:
- (void)registerForRemoteNotificationTypes:(UIRemoteNotificationType)types
You could also prevent backgrounding by setting the “Application does not run in background” property in the application’s Info.plist file (UIApplicationExitsOnSuspend).