Badges, Update item number? - iphone

Is it possible to update the badge number without sending the application a push notification?
Such as when the application is loaded you can change the badge number?

Yes. You can use this:
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:3];
This will update the value without using a push notification.

Related

How can I temporarily disable all local notification scheduled by my iPhone app?

Is there any method to temporarily disable all local notifications created by an iPhone app? I need to re enable them all with respect to a condition. my requirement is if the user turned off the notification button on my app , then no more notifications is shown.If he turned it on then all notifications should be shown. Any idea?
You can get all scheduled notifications and save them in shared preferences for example.
[[UIApplication sharedApplication] scheduledLocalNotifications];
Then cancel all notifications:
- (void)cancelLocalNotification:(UILocalNotification *)notification
If user activate notifications again, you can reschedule them again.
You can use "cancelAllLocalNotifications" method and When User turn it On you can set again All notification for it.

can application find out if push notifications are enabled or disabled?

Can my application find out if push notifications were disabled through Settings on the device? I am not talking about checking with feedback.push.apple.com. I would simply like to know if the switch in the Settings was set to ON or OFF.
You can use
[[UIApplication sharedApplication] enabledRemoteNotificationTypes]
If this returns UIRemoteNotificationTypeNone which is equal to the value 0, then the application accepts no notifications. Hope this helps you.
You can find out which kind of notifications are enabled for your app using [[UIApplication sharedApplication] enabledRemoteNotificationTypes].

Reducing badge number with Push notifications

Hi in my application when i receive push notification from server my application badge get incremented by one.and when i open app and close it did not get reduce.so my question is how to reduce badge icon on application icon when user see the notification
You can set it to any value you like. Setting it to 0 removes the badge.
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
I had this same issue, so I thought, "Why not just GET the badge number?" Then, you can do whatever you wish with it.
If you are in your AppDelegate.m file, you could use this in your application: didFinishLaunchingWithOptions: method:
int badgeNumber = [application applicationIconBadgeNumber] -1;
[application setApplicationIconBadgeNumber:badgeNumber];
This will reduce the icon badge number by one. However, be mindful that your user may have multiple notifications from your application that are still not yet viewed. Thus, you should probably set this inside of a particular method that will handle the pushes. Or, depending how your app is set up, just set the badge icon number to 0.
Hope this helps.

iOS Persistent Notification / Quick Launch

I'm curious if anyone can provide information on how apps like AppSwitcher use the notification center to create persistent quick-launch notifications.
I know that they are using a url to do launch apps, but what I'm looking for is how to create the notification and keep it persistent.
If your app creates a notification and doesn't clear notifications programmatically, it will remain in Notification Center until the user clears all notifications from your app.
The best I've been able to come up with is calling something like a following ever so often:
[[UIApplication sharedApplication] cancelLocalNotification:localNotification];
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
This will delete the current notification, and replace it with a new one. However, it's not really persistent, and another drawback is that the screen will turn on when the notification gets refreshed. Still searching for a better way.

can we show badge without APNS?

I want to simulate push notification without using apple's push notification server, so I want to know can I show badge also if yes which API or Objective-C code I have use to show badge?
Yes. Use [[UIApplication sharedApplication] setApplicationIconBadgeNumber:<n>]. See the documentation.
We can use [[UIApplication sharedApplication] setApplicationIconBadgeNumber:<n>] to show the badge with out APNS.
If we want to reset the previous badge while application is restarted ,we can use this
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];