Issue with UIAlertView is depreciated

214 Views Asked by At

I am creating my first IOS App with Cordova 10 and I am very novice as it's my first APP. On cordova, I installed two plus gin

  • cordova-plugin-notification
  • cordiva-plugin-network-information

I installed the first only to make the smartphone ringing. I do not need the alert, propt (ect) I installed the second only to check if the smartphone is connected over the WiFi or the gsm network.

Actually, I simulate my App with Xcode a I have a lot of warning as

UIAlertView' is deprecated: first deprecated in iOS 9.0

'currentRadioAccessTechnology' is deprecated: first deprecated in iOS 12.0

As I am very notice with ObjectiveC, I really have no idea how to update the plugins, but first how to update the depreciate function.

From that point, I have some quetions

Q1: Is there a way to ring the Smartphone without the cordova-plugin-notification?

But it would be better to update the code or comment the unusfull code. I also read,

Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead

Q2. How can I simply replace UIAlertController and adapt the following code, without breaking my App? Keeping in mind, I have not develop the plugins and I am novice with ObjectivC (I am afraid to break the App by modifying this part of code)

[Edit] Here is an example of a function which give trouble

  * Callback invoked when an alert dialog's buttons are clicked.
  */
- (void)alertView:(UIAlertView*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    CDVAlertView* cdvAlertView = (CDVAlertView*)alertView;
    CDVPluginResult* result;

    // Determine what gets returned to JS based on the alert view type.
    if (alertView.alertViewStyle == UIAlertViewStyleDefault) {
        // For alert and confirm, return button index as int back to JS.
        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:(int)(buttonIndex + 1)];
    } else {
        // For prompt, return button index and input text back to JS.
        NSString* value0 = [[alertView textFieldAtIndex:0] text];
        NSDictionary* info = @{
            @"buttonIndex":@(buttonIndex + 1),
            @"input1":(value0 ? value0 : [NSNull null])
        };
        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:info];
    }
    [self.commandDelegate sendPluginResult:result callbackId:cdvAlertView.callbackId];
}

For the developer, who know well Cordova, is there a workaround to check the network and to sound a bip?

Many thank for your advises

0

There are 0 best solutions below