Ich bin versucht, die Nachricht innerhalb einer Push-Benachrichtigung durch den AppDelegate enthält angezeigt werden, wie in der parse.com Dokumentation beschrieben.angezeigte Warnung von AppDelegate vor Benachrichtigung von viewDidLoad Anzeigen
Das Problem, das ich habe ist, dass für meine ersten View-Controller in meiner viewDidLoad Methode, ich eine Warnung vorstelle, die der Benutzer sehen muß, bevor sie die App verwenden.
Wie kann ich die Methode von meinem AppDelegate, nachdem der Benutzer rufen Sie die Benachrichtigung von der viewDidLoad Methode sieht?
EDIT:
Also ich habe, wie es in den Kommentaren vorgeschlagen, eine globale Variable hinzugefügt, die ich auf true gesetzt, sobald ich die Warnung von meiner viewDidLoad Methode angezeigt, aber die Meldung Benachrichtigung von meiner AppDelegate noch erscheint nicht.
hier ist meine App delegate.m Datei:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
[Parse setApplicationId:@"xxxxxxxxxxxxxxxx"
clientKey:@"xxxxxxxxxxxx"];
// Register for Push Notitications, if running iOS 8
if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert |
UIUserNotificationTypeBadge |
UIUserNotificationTypeSound);
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes
categories:nil];
[application registerUserNotificationSettings:settings];
[application registerForRemoteNotifications];
} else {
// Register for Push Notifications before iOS 8
[application registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeAlert |
UIRemoteNotificationTypeSound)];
}
return YES;
NSDictionary *notificationPayload = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey];
if (Notification == true) {
if (![pushText isEqual: @""]) {
pushText = [[notificationPayload objectForKey:@"aps"] objectForKey:@"alert"];
UIAlertView *alert_news = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"News", "")
message:pushText
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles: nil];
[alert_news show];
}
}
}
Und hier Methode meine viewDidLoad ist:
RoadSafetyAppAppDelegate *AppDelegate;
- (void)viewDidLoad
{
AppDelegate = (RoadSafetyAppAppDelegate *)[[UIApplication sharedApplication] delegate];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
backgroundImage.alpha = 0.3;
toRecipients = [[NSArray alloc]initWithObjects:@"[email protected]", nil];
static int appCounter;
if (appCounter < 1 ) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Disclaimer", "")
message:NSLocalizedString(@"Using a mobile phone whilst driving is against the law. Ensure that you are not behind the wheel when using this app.", "")
delegate:nil
cancelButtonTitle:@"I agree to not use a mobile phone while driving"
otherButtonTitles: nil];
[alert show];
appCounter = appCounter+1;
AppDelegate.NotificationAlert = @"1";
AppDelegate.Notification = true;
}
}
Vom AppDelegate können Sie eine showPushMessage Bool Variable innerhalb des View-Controller gesetzt, zeigen dann die Push-Nachricht Alarm nach dem ersten Alarm im Falle des Feldes verwiesen, dass showPushMessage == YES. –
könnten Sie ein wenig Code zur Verfügung stellen, nur um dies zu skizzieren? Ich bin ein bisschen neu das AppDelegate selbst für zusätzliche Manipulation – scb998
Die App zu verwenden, sollte sofort den Push-Benachrichtigung Alarm angezeigt, wenn die App bereits geöffnet ist, und der Benutzer hat bereits akzeptiert Ihren Haftungsausschluss Alarm, nicht wahr? –