bitstadium / HockeySDK-iOS

HockeyApp was retired and the SDKs are deprecated. Please use App Center instead.
https://github.com/microsoft/appcenter-sdk-apple
Other
597 stars 268 forks source link

Set Custom AlertViewHandler Documentation #506

Closed kwstasna closed 6 years ago

kwstasna commented 6 years ago

Hello and congrats for the analytics service.

I would like to raise this case so you can update the documentation

https://www.hockeyapp.net/help/sdk/ios/5.1.2/set-custom-alertviewhandler.html

Since AlertView is Deprecated.

For example (working code)


BITHockeyManager.shared().crashManager.setAlertViewHandler {
           let exceptionReason = BITHockeyManager.shared().crashManager.lastSessionCrashDetails.exceptionReason
                let alertController = UIAlertController(title: "Oh no! The App crashed", message: "We would like to send a crash report to the developers. Please enter a short description of what happened:", preferredStyle: .alert)
                let sendReport = UIAlertAction(title: "Send Report", style: .default, handler: {
                    alert -> Void in
                    let crashMetaData = BITCrashMetaData()
                    crashMetaData.userProvidedDescription = alertController.textFields![0].text
                    BITHockeyManager.shared().crashManager.handle(BITCrashManagerUserInput.send, withUserProvidedMetaData: crashMetaData)

                })

                let cancelAction = UIAlertAction(title: "Cancel", style: .default, handler: {
                    (action : UIAlertAction!) -> Void in

                })

                alertController.addTextField { (textField : UITextField!) -> Void in
                    textField.placeholder = "Enter text here..."
                }
                alertController.addAction(sendReport)
                alertController.addAction(cancelAction)

                self.present(alertController, animated: true, completion: nil)
        }

FYI the above code is used inside the ViewController's viewDidAppear method.

ElektrojungeAtWork commented 6 years ago

Hey Kwstasna,

thx for this. I somehow missed this part when I updated the docs... I'll update the documentation.

Best, Benjamin

ElektrojungeAtWork commented 6 years ago

I just merged the PR for this – the docs will be updated in the next release. I'll close this issue.

Thx again for letting us know.