2017-12-12 1 views
1

저는 UIAlertController를 사용하여 강제 업데이트를 위해 사용자를 홍보하는 응용 프로그램 중 하나에서 작업하고 있습니다.이 응용 프로그램에서는 사용자가 Appstore에서 응용 프로그램을 업데이트 할 때까지 활동을 수행하지 못하도록하고 싶지 않습니다. .UIAlertController에서 UIAlertController가 닫히는 것을 방지합니다.

이 작업을 수행하려면 다음 코드를 작성해야합니다.

if (needToUpdate) 
    { 
     var alert = UIAlertController(title: "New Version Available", message: "There is a newer version available for download! Please update the app by visiting the Apple Store.", preferredStyle: UIAlertControllerStyle.Alert) 
     alert.addAction(UIAlertAction(title: "Update", style: UIAlertActionStyle.Default, handler: { alertAction in 
      UIApplication.sharedApplication().openURL(NSURL(string : "https://itunes.apple.com/app/cheapo-casino-free-casino/id637522371?ls=1&mt=8")!) 
      alert.dismissViewControllerAnimated(true, completion: nil) 
      })) 
     self.presentViewController(alert, animated: true, completion: nil) 
    } 

사용자가 업데이트 버튼을 누를 때마다 앱 스토어로 이동하고 사용자가 응용 프로그램을 업데이트하지 않으면 작동합니다. 그/그녀는 신청서로 돌아가 예상치 못한 활동을 수행 할 수 있습니다.

사용자가 업데이트 버튼을 눌러도 UIAlertController를 표시 할 수있는 방법이 있습니까?

+5

FYI - 애플은 실제로 당신이하는 일을 애플 리케이션을 원하지 않습니다. 사용자가 업데이트 여부를 결정하도록합니다. 개인적으로 나는 원하지 않을 때 업데이트하도록 강요하는 앱을 싫어합니다. – rmaddy

+1

위의 설명에 기본적으로 동의하지만 나는 닫아야합니다. 왜 'dismissViewControllerAnimated'를 호출할까요? –

+0

이 링크가 도움이 될 것입니다. https://stackoverflow.com/questions/28919670/prevent-uialertcontroller-to-dismiss –

답변

1

당신은 AppDelegate에있는 응용 프로그램의 버전을 확인할 수 있습니다.

func applicationDidBecomeActive(_ application: UIApplication) { 
    //check the app version here and if version mismatch is there show the alert. 
    // if the version is different then make initial viewController as root view controller. and then present alert from that view controller. 
} 
1

강제로 업데이트하는 것은 매우 나쁜 사용자 환경입니다. 조심해서 진행하십시오! 앱 스토어 리뷰 팀의 승인을받지 못할 수도 있습니다.

  • 업데이트를 사용할 수있다, 화면 전체를 커버하는 새로운 볼 수있는 응용 프로그램의 기본보기를 숨기 :

    여러 가지 방법이 있습니다. 이제 사용자는 아무 것도 할 수 없습니다.

  • "새로운 업데이트!" viewDidAppear 또는 applicationDidBecomeActive으로 경고하므로 사용자가 앱으로 돌아가더라도 새로운 알림이 표시됩니다.

  • "새로운 업데이트!" 이전의 "새 업데이트!"의 UIAlertAction 때 다시 경고하십시오. 경고음이 울립니다.

+0

당신은 어떤 view controller viewdid가 그가 코드를 쓸지를 말해 줄 수 있습니까? –

+0

@RahulDasgupta 'UIAlertController'를 표시하는 동일한 VC입니다. – Sweeper

+0

애플 리케이션에 50보기 컨트롤러가 있다면 그는 50 모든 UIViewController에서 작성해야합니다 –

관련 문제