Meraki guided access not working on iPAD - guided-access

I am trying for for Single App mode for one of my App using "Meraki" MDM, registered the device on the MDM site and created the profile.
I am using below code as suggested in this site, the code works fine on simulator but not on iPad."UIAccessibilityRequestGuidedAccessSession" is not fired. Can someone help me what I am missing here.
NSLog(#"requesting guided access");
UIAccessibilityRequestGuidedAccessSession(YES, ^(BOOL didSucceed) {
if (didSucceed) {
NSLog(#"entered guided access");
self.inGuidedSessionMode = YES;
[[[UIAlertView alloc] initWithTitle:#"entered single access mode" message:nil delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil] show];
}
else {
NSLog(#"failed to enter guided access");
[[[UIAlertView alloc] initWithTitle:#"Unable to enter single access mode" message:nil delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil] show];
}
});

This will only work if the device is supervised, which is done through Apple Configurator or the Apple Device Enrollment Program.

Related

cannot receive push notification on iphone from Azure notification hub

I've created an iphone app with push notification using Azure notification hub. But I'm having a hard time getting the push to work.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
/******** code for Push notification **********/
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
[[UIApplication sharedApplication] registerForRemoteNotifications];
NSLog(#"Entered appDelegate didFinishLaunchingWithOptions");
return YES;
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *) deviceToken {
SBNotificationHub* hub = [[SBNotificationHub alloc] initWithConnectionString:#"<my azure listening connection string>" notificationHubPath:#"myhub"];
NSLog(#" DeviceToken: %#",deviceToken);
[hub registerNativeWithDeviceToken:deviceToken tags:nil completion:^(NSError* error) {
if (error != nil) {
NSLog(#"Error registering for notifications: %#", error);
}
else {
[self MessageBox:#"Registration Status" message:#"Registered"];
}
}];
}
-(void)MessageBox:(NSString *)title message:(NSString *)messageText {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title message:messageText delegate:self cancelButtonTitle:#"OK" otherButtonTitles: nil];
[alert show];
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification: (NSDictionary *)userInfo {
NSLog(#"%#", userInfo);
[self MessageBox:#"Notification" message:[[userInfo objectForKey:#"aps"] valueForKey:#"alert"]];
}
I've followed the steps form this document:
https://azure.microsoft.com/en-us/documentation/articles/notification-hubs-ios-get-started/
I've created an explicit app id on the Member center and it matches my bundle id. I'm using developer cert and chose "sandbox" under Azure.
When I first launched my app on to my iphone (not simulator) I get the prompt to accept push notifications - I chose yes. Then my code gets a token from apple and registers that with Azure NH, which is successful.
From Azure NH debug tab, I did a broadcast send which was successfully sent from Azure to APNS. But I never received any notifications. Here is the body of the push notification message on Azure:
{"aps":{"alert":"Notification Hub test notification"}}
I have tried this multiple times and even created an isolated project just to test push notification (separate certs, provisioning profile etc) and it still does not work.
When I intentionally malform the payload of the message for Push, I do get an error as expected So it seems that the connection from NH to APNS is good.
My requirement is to send around 100 million pushes a month.
If anyone has used Azure notification for push notifications then please advice how to fix this?
If anyone has had poor experience with Azure NH then please share what you ended up migrating to.
Thanks in advance.
I was able to get this to work.
I deleted all certificates on Apple developer center and my mac. I recreated the certificates and then followed the process again. It all worked out this time.
Thanks.

Why are all my UIAlertView labels/text bold by default in iOS 8

I searched for this and the only solutions seem to be derive from the UIAlertViewDelegate. I don't want to do that just to eliminate bold text.
The code that I use to pop my alert view is the following:
NSString* errPrompt = #"some text here, anything that will not show bold :)";
UIAlertView* alert = [[UIAlertView alloc] initWithTitle:title
message:errPrompt
delegate:nil
cancelButtonTitle:[self getUiText:"OK"]
otherButtonTitles:nil];
[alert show];
This is a bug in iOS and affects all alerts which do not have a title set.
Interestingly most standard iOS alerts (like in App Store) are not affected.
This works for me on iOS 8. Just empty string in the title without space inside #"".
[[[UIAlertView alloc] initWithTitle:#""
message:#"My message"
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil] show];
This happens when you do not set Alert title. (Weird, I know)
Set Alert's title as. empty if you. do not want to add any title
UIAlertController(title: "", message: "The alert message", preferredStyle: .alert)

UIAlertView with UIImageView in accessoryView

I am giving an UIImageView in the UIAlertView's accessoryView by the following code:
UIAlertView *alertView = [[UIAlertView alloc]init];
[alertView addButtonWithTitle:#"Cancel"];
[alertView addButtonWithTitle:#"OK"];
UIImageView *someImageView = /*initialization code */;
[someImageView setFrame:CGRectMake(0,0,40 ,20)];
[alertView someImageView forKey:#"accessoryView"];
[alertView show];
The above code works fine with iOS7 but since the update to iOS8 the alertView looks elongated and disoriented. I have tried changing the constraints and the aspect ratio of the image that is set in the UIImageView.
Can someone help me with this?
This is not a supported use of UIAlertView:
The UIAlertView class is intended to be used as-is and does not support subclassing. The view hierarchy for this class is private and must not be modified.
Additionally, UIAlertView is deprecated in iOS 8.
You should build your own view to present, or use one of the many open-sourced options on GitHub/CocoaControls, like SDCAlertView or ios-custom-alertview.

how to auto dismiss UIAlertView when app becomes active

OK, I have an app that runs a timer. If the user is watching the app's timer count down (e.g. the app is awake and active in the foreground) I want an alert to be shown to the user. I've added this code to my timer when it reaches 0:
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Reminder" message:#"It's time!" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil, nil];
[alert show];
The problem I'm having is that if I put the phone to sleep or make the app inactive in some other fashion I have a local notification setup to handle this alerting so when the user goes back to the app I don't want them to see the alert mentioned above. It's an unnecessary "click" they have to make.
Is there a way to auto dismiss this alert when the app either goes into the background or enters the foreground if it's been triggered?
You have to use NSNotificationcenter at the UIAlertview definition.
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title message:message delegate:nil cancelButtonTitle:nil otherButtonTitles:#"OK",nil];
[alert show];
[[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillResignActiveNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification* notification){
[alert dismissWithClickedButtonIndex:0 animated:NO];
}];
There is no auto dismiss.
You have to communicate that your app become active (from UIApplicationDelegate) to your UIAlertView.
To do so, many techniques exists, you could keep reference of that alert in AppDelegate to dismiss it, or use some NSNotification posted from delegate and observed in your ViewController or anywhere you are showing this alert.
Alternatively you could use... https://github.com/sdarlington/WSLViewAutoDismiss

Removeallobjects in array from another view? Xcode iOS

Please forgive me is this is too vague. I have an app that has populated arrays based on where the user browses to. One is just all sites visited and is accessible in another viewcontroller and another is all text input in to the textview which is displayed while the user types. I don't know if any of that is important but my question is, I would like to have a settings page that has the option to clear that data. I can do it from the header file in that view its self but not sure how to send the removeallobjects command to other views or arrays.
In each view I have a button to call this:
-(IBAction)clearPreText {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:#"clear all predictive typing?"
message:#"press ok to clear"
delegate: self
cancelButtonTitle:#"cancel"
otherButtonTitles:#"ok", nil];
[alert show];
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 1) {
[pastUrls removeAllObjects];
[[NSUserDefaults standardUserDefaults] setObject:autocompleteUrls forKey:#"PastUrls"];
[self.autocompleteTableView reloadData];
}}
I would like to place those buttons in a new view, a settings page.
Thanks for anything.
Both controllers will have access to the app delegate and the app delegate will have access to each of your controllers. When I need to do something like this, I usually do it through the app delegate.

Resources