Update Status of current location -iOS - ios

How can I get this small thumbnail status on the right corner of the icon?

You can use the setApplicationIconBadgeNumber: method to set the badge to any number you want. This message should be sent to an instance of UIApplication. To get the current application, you simply call [UIApplication sharedApplication].
Your code would look like this:
int number = 25; //set this to any number you want
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:number];
Or, you can obviously set it at once, without the extra variable, like this:
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:25];

For the badge see
http://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplication_Class/Reference/Reference.html#//apple_ref/occ/instp/UIApplication/applicationIconBadgeNumber or use
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:68];
For the new icon, you can't this is done by apple when you download a new application and it hasn't been opened yet.

Use application badge to set like that.
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:68];
For more reference, see this
Also see UIApplication documentation

Related

Programmatically delete Remote Notifications from Notification Centre

How can we pragmatically remove any pending remote notifications sent for my app from notification centre. I want to clear them up on app launch.
I have tried with [[UIApplication sharedApplication] cancelAllLocalNotifications]; API but its not helping.
PS: This question is specific to iOS 10 and old threads are not duplicates for this one.
Finally...
This one works like charm!
[[UNUserNotificationCenter currentNotificationCenter] removeAllDeliveredNotifications];
You can clear all notifications from notification centre by using these simple lines of code
[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 1];
[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 0];
[[UIApplication sharedApplication] cancelAllLocalNotifications];
use wherever you want. From my side I have used when user pressed logout.
You can use in
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
method to clear notifications after app opens
AFAIK, you should do it by using the background mode for remote notifications, and then responding to these notifications by issuing a local notifications.
You can remove local notifications, but not remote notifications.
Reseting the application badge number also remove all the notifications (local & remote) from the notification center.
Objective C
[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
Swift
UIApplication.shared.applicationIconBadgeNumber = 0
This can definitely be achieved by using removeDeliveredNotifications(withIdentifiers:) method available in UserNotifications.framework.
For a detailed tutorial, please follow this
https://medium.com/#sebastianosiski/implementing-removable-remote-notifications-on-ios-a17d74832bde

Disable remote controls iOS

By default, remote control is activated on my streaming application but under a certain circumstance I want to disable all controllers and show nothing when the screen is locked.
First I tried to set now playing info to nil like this [[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo: nil]; and all text, image and progress disappear but the control buttons and volume bar was still showing.
After that I tried this [[UIApplication sharedApplication] endReceivingRemoteControlEvents]; but it gives me nothing, it shows the same thing on the screen as the previous method call.
For the record, I'm calling [[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; on AppDelegate before I tried to call any of the previous methods.
So, I have not found anything related to this that could help me with my problem and I would appreciate any help :)

How to find out the Icon Badge count?

I'm using push notifications on my iOS app and everything is working great.
The icon badge is working and when I open the app I clear it with this code:
[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 0];
But before clearing it I would like to find out what is the badge count to make some changes on the app according to the number of notifications the user has when opening the app.
Is it possible to do get this number?
Thanks!
[UIApplication sharedApplication].applicationIconBadgeNumber
Try

remove the alert that pops up when calling from iOS app using telprompt://

I need to make a call from my iOS app, and after the user is done calling, i need him to come back on the same app screen from where he made the call. if i use the following code
NSString *phoneNumber = [#"telprompt://" stringByAppendingString:#"999999999"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber]];
i achieve what i want, but get an unwanted alert confirming if the user wants to make a call or not. I don't want this.
If i use the code
NSString *phoneNumber = [#"tel://" stringByAppendingString:#"999999999"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber]];
i do not get the alert, but i do not get back to my app screen too..!!
Is there a way where i do not get the alert while making the call and get back to the app screen after making the call?? please help..
You cannot do otherwise, those are the two possibilities. telprompt with alert and callback or tel with not coming back and no alert.
If the users leaves the app to make a phone call, there's no way you can return to your app after it. Your app is backgrounded, and the phone app is foregrounded.

iPhone display screen lights not turning off automatically

I have observed that my I run my iPhone application (native) the display lights are not turning off as they usually do in other applications, I have waited for couple of minutes but it wont turn off until I exit my application.
Is there anything which I had messed up with that is not causing the automatic dimming?
[[UIApplication sharedApplication] setIdleTimerDisabled:NO];
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
Are the two lines to enable/disable the dimming of the screen in an iOS app. Double check and see if your app has any of these.
Put this code into application didFinishLaunchingWithOptions: method.
Have you used this in your app?
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
If so, remove it or set it to NO.

Resources