簡體   English   中英

每月啟動UIalert View

[英]Initiate an UIalert View monthly

我想每月(例如每月1號)進行一次提醒,以提醒用戶對我的應用程序進行評分。 我在首次打開應用程序時就搜索了打開警報視圖的方法,但是沒有解決問題的答案。 誰能幫我以下代碼。

非常感謝。

- (void)viewDidLoad{
    [super viewDidLoad];

    NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
    NSString *alreadyRun = @"already-run";
    if ([prefs boolForKey:alreadyRun])
        return;
    [prefs setBool:YES forKey:alreadyRun];
    UIAlertView *alert = [[UIAlertView alloc]
                          initWithTitle:@"Rate and Comment" message:@"Thank you for choosing Art of Codes, your support could make this app better. Please rate and comment and tell us what you think."delegate:self cancelButtonTitle:@"Done" otherButtonTitles:@"Rate it!", nil];
    [alert show];
 }

- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
    // the user clicked one of the OK/Cancel buttons
    if (buttonIndex == 0)
    {
        NSLog(@"ok");
    }
    else
    {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://itunes.apple.com/"]];
    }
}   

如果您確實想執行此操作(並且我建議您不要出於UX的考慮),一種簡單的方法是將NSDate對象寫入上次顯示消息時的standardUserDefaults中。 您可能不需要整個日期,可能只是一個月和一天。 在應用啟動時,將存儲的日期與當前日期進行比較,看看是否該顯示警報了。 如果是,請更新保存的日期並顯示警報。

同樣,建議您不要顯示警報。 如果人們想對您的應用程序進行評分,他們會的。 通知唯一要做的就是惹惱您的用戶,並可能對您的應用產生負面評價。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM