ios – Get the variety of widget put in in swift

[ad_1]

I attempt to create a react-native native module in swift, and I wish to get the variety of widgets put in in consumer machine.

I attempt one thing like :

  @objc
  func nbOfWidgetInstalled(_ callback: RCTResponseSenderBlock) -> Void {
    var numb = 0;
    if #accessible(iOS 14.0, *) {
      WidgetCenter.shared.getCurrentConfigurations {
        (end result) in
        swap end result {
        case .success(let widgetInfos):
          numb = widgetInfos.rely
        case .failure(let error):
          // do this to see if the quantity is up to date...
          numb = 3
        }
      }
    } else {
      // do this to see if the quantity is up to date...
      numb = 2
    }
    callback([numb])
  }

However the quantity returned is all the time 0 like if numb is rarely up to date.

Why numb will not be up to date when it cross via the circumstances ?

Thanks

[ad_2]

Leave a Reply