Wikitude black screen on iOS 8.3

343 views Asked by At

Right now right after user approved the permissions for a camera and GPS I have black screen with pois. It semms like there is an issue realted to the camera, because pois are moving on device position change so that part works nice, in addtion if I kill the app and then start it everyting is fine (User already approved the permissions) Any thoughts what could be the issue ? Code bellow :

- (void)viewDidLoad {
    [super viewDidLoad];
    NSError *deviceNotSupportedError = nil;
    if ( [WTArchitectView isDeviceSupportedForRequiredFeatures:WTFeature_Geo error:&deviceNotSupportedError] ) { // 1
        self.architectView.delegate = self;
        [self.architectView setLicenseKey:@""];

        self.architectWorldNavigation = [self.architectView loadArchitectWorldFromURL:[[NSBundle mainBundle] URLForResource:@"index" withExtension:@"html" subdirectory:@"4_PointOfInterest_4_SelectingPois"] withRequiredFeatures:WTFeature_Geo | WTFeature_2DTracking];

        [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification
                                                          object:nil
                                                           queue:[NSOperationQueue mainQueue]
                                                      usingBlock:^(NSNotification *note) {
                                                          if (self.architectWorldNavigation.wasInterrupted) {
                                                              [self.architectView reloadArchitectWorld];
                                                          }
                                                          [self startRunning];
                                                      }];

        [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillResignActiveNotification
                                                          object:nil
                                                           queue:[NSOperationQueue mainQueue]
                                                      usingBlock:^(NSNotification *note) {
                                                          [self startRunning];
                                                      }];

    } else {
        NSLog(@"device is not supported - reason: %@", [deviceNotSupportedError localizedDescription]);
    }
}

-(void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self startRunning];
}

- (void)startRunning {

    if ( ![self.architectView isRunning] ) {
        [self.architectView start:^(WTStartupConfiguration *configuration) {
            configuration.captureDevicePosition= AVCaptureDevicePositionBack;

        } completion:^(BOOL isRunning, NSError *error) {
            if ( !isRunning ) {
                NSLog(@"WTArchitectView could not be started. Reason: %@", [error localizedDescription]);
            }
        }];
    }
}
2

There are 2 answers

0
Łukasz Tomaszewski On BEST ANSWER

I fixed this issue by check on UIApplicationDidBecomeActiveNotification notification if the Wikitude engine is on. If not I execute Wikitude's start method and everything works fine.

    - (void)startRunning {
    self.observers = [[NSMutableArray alloc] init];
    NSError *deviceNotSupportedError = nil;
    if ( [WTArchitectView isDeviceSupportedForRequiredFeatures:WTFeature_Geo error:&deviceNotSupportedError] ) {
        self.architectView.delegate = self;
        self.architectView.desiredLocationAccuracy = kCLLocationAccuracyNearestTenMeters;
        [self.architectView setLicenseKey:kWikiTudeLicenseKey];

        NSURL *architectWorldUrl = [[NSBundle mainBundle] URLForResource:@"index" withExtension:@"html" subdirectory:kWikitudeHTMLFileSubDictionary];
        self.architectWorldNavigation = [self.architectView loadArchitectWorldFromURL:architectWorldUrl withRequiredFeatures:WTFeature_Geo];

        for (id object in self.observers) {
            [[NSNotificationCenter defaultCenter] removeObserver:object];
        }

        id observer = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification
                                                                        object:nil
                                                                         queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {

                                                                             if (self.architectWorldNavigation.wasInterrupted) {
                                                                                 [self.architectView reloadArchitectWorld];
                                                                             }
                                                                             [self startServiceIfNeeded];
                                                                         }];
        id observer1 = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillResignActiveNotification
                                                                         object:nil
                                                                          queue:[NSOperationQueue mainQueue]
                                                                     usingBlock:^(NSNotification *note) {
                                                                         if ( [self.architectView isRunning] )
                                                                         {
                                                                             [self.architectView stop];
                                                                         }
                                                                     }];
        [self.observers addObject:observer];
        [self.observers addObject:observer1];
    } else {
        DLog(@"device is not supported - reason: %@", [deviceNotSupportedError localizedDescription]);
    }

    if ( ![self.architectView isRunning] ) {
        [self.architectView start:^(WTStartupConfiguration *configuration) {
            configuration.captureDevicePosition = AVCaptureDevicePositionBack;
        } completion:^(BOOL isRunning, NSError *error) {
            if ( !isRunning ) {
                NSLog(@"WTArchitectView could not be started. Reason: %@", [error localizedDescription]);
            }
            self.didStart = isRunning;
            if (self.didStartedEngine) {
                self.didStartedEngine();
            }

        }];
    }
}

    - (void)startServiceIfNeeded {
        if ( ![self.architectView isRunning] ) {
            [self.architectView start:^(WTStartupConfiguration *configuration) {
                configuration.captureDevicePosition = AVCaptureDevicePositionBack;
            } completion:^(BOOL isRunning, NSError *error) {
                if ( !isRunning ) {
                    NSLog(@"WTArchitectView could not be started. Reason: %@", [error localizedDescription]);
                }
            }];
        }
    }
0
Vicky On

Set Other Linker Flags to -ObjC for both Debug and Release on Build Settings.enter image description here