Start a new topic

Basic example of Wikitude SDK javascript iOS

 Hi all,


I'm trying to develop a simple app in iOS, using Wikitude SDK Javascript for iOS (8.10.0): a view showing the architectworld.


I've done perfectly in Android by following the guide here:

https://www.wikitude.com/documentation/latest/android/gettingstartedandroid.html


On the other hand, I've followed the documentation for iOS (i'm quite new to Objc):

https://www.wikitude.com/external/doc/documentation/latest/ios/setupguideios.html?_ga=2.224573725.661799696.1581332934-1993112458.1580135856


It seems all ok, but the Camera doesn't start and the AR world is not displayed...


Here the code in the ViewController (the only one I have in the app, obviously with the correct license key):




#import "ViewController.h"
#import <WikitudeSDK/WikitudeSDK.h>


@interface ViewController ()

@property (nonatomic, strong) WTArchitectView               *architectView;
@property (nonatomic, strong) WTNavigation               *WTNavigation;

@end

@implementation ViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
   
    NSError *deviceNotSupportedError = nil;
   
    printf("initializing");
   
    if ( [WTArchitectView isDeviceSupportedForRequiredFeatures:WTFeature_Geo | WTFeature_ImageTracking error:&deviceNotSupportedError] ) { // 1
        self.architectView = [[WTArchitectView alloc] init];
        self.architectView.delegate = self;
        self.architectView.requiredFeatures = WTFeature_ImageTracking; // 2
        [self.architectView setLicenseKey:@"**HERE I HAVE MY LICENSE KEY THAT I DO NOT REPORT HERE..."]; // 3
        [self.view addSubview:self.architectView]; // 4
        // ...
        printf("supported");
       
       //[self startRunning];
        //NSLog(@"device is supported - reason: %@", "ok");
   
        printf("creo");
        NSURL *architectWorldURL = [[NSBundle mainBundle] URLForResource:@"index" withExtension:@"html" subdirectory:@"ArchitectWorld"];
        [self.architectView loadArchitectWorldFromURL:architectWorldURL];
        printf("creato");
   
    } else {
        printf("not supported");
        //NSLog(@"device is not supported - reason: %@", [deviceNotSupportedError localizedDescription]);
    }
   
   
   
}


- (id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super initWithCoder:aDecoder];
    if (self) {
        NSLog(@"initialization");
    }
   
   
    return self;
}

// from: https://stackoverflow.com/questions/30816661/wikitude-does-not-work-poi-do-not-change-the-position-on-phone-position-change
/*
- (void)startRunning {
    printf("starting");
    NSURL *architectWorldURL = [[NSBundle mainBundle] URLForResource:@"index" withExtension:@"html" subdirectory:@"ArchitectWorld"];
    [self.architectView loadArchitectWorldFromURL:architectWorldURL];
    printf("started");
}
 */

- (void)viewWillAppear:(BOOL)animated {
   
    [super viewWillAppear:animated];
   
    printf("hello");
   
    printf("appeared");
   
    /* WTArchitectView rendering is started once the view controllers view will appear */
   
    //[self startRunning];
   
    [self startWikitudeSDKRendering];
   
}

- (void)startWikitudeSDKRendering{
   
   
   
    printf("rendered");
   
    [self.architectView start:^(WTStartupConfiguration *configuration) {
       
       
        //configuration.captureDevicePosition = AVCaptureDevicePositionBack;
       
        printf("rendered2");
       
       
    } completion:^(BOOL isRunning, NSError *error) {
       
        printf("rendered3");
       
    }/*
                   completion:^(BOOL isRunning, NSError *error) {
                       if ( !isRunning )
                       {
                           printf("notrun");
                       }
                      
                   }
      */
     ];
   
   
   
   
    }

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
   
    printf("goodbye");
   
    [self.architectView stop];
   
    /* iOS 8 requires to set the interactivePopGestureRecognizer to nil in order to prevent a crash in the underlying vc */
    self.navigationController.interactivePopGestureRecognizer.delegate = nil;
}


@end




It saw all the printf but the AR world/camera does not appear (I've added the files, and I have an alert in the "imageontarget.js" that is shown in the app...without camera)


I've added also the correct keys in the info.plist, as following:


<key>NSCameraUsageDescription</key>
    <string>Accessing the Camera is required to run the Wikitude SDK</string>
    <key>NSLocationWhenInUseUsageDescription</key>
    <string>Accessing GPS information is needed to display POIs around your current location</string>
    <key>NSPhotoLibraryUsageDescription</key>
    <string>Access to your photo library is required for the example 'Bonus: Capture Screen' because it adds a screenshot of the current Architect view</string>
    <key>NSPhotoLibraryAddUsageDescription</key>
    <string>Access to your photo library is required for the example 'Bonus: Capture Screen' because it adds a screenshot of the current Architect view</string>
    <key>UISupportedInterfaceOrientations~iphone</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>


Thank you in advance,


Ricc



Hi Ricc,


Thx for the feedback. From what it sounds (as you see content from the .js file from the AR experience, and only the camera image is black), there might be something missing with the Camera Permission handling.


Unfortunately we can't create a specific app for you. For a starting point, if someone is new to our SDK, we're providing the SDK sample app with the extensive technical documentation. Unfortunately we can't provide support in regards to ObjC and its standard concepts, if a developer is new to the ObjC or Android. This would not be manageable by our team. 


Thx and greetings

Nicola

Hi Nicola,


I ran the sample app in Xcode and evrything is fine. However, it is quite complex and, being me new to ObjC, I can't extract only some functions from that..


I need to create my "empty" App that only runs Architect views for image recognition, focusing all the effort on the creation of AR worlds.


I've seen that for JS Android the documentations provide a complete guide to create a basical AR app (also for Android newbies like me, of course), but the JS iOS doc only suggests something that I'm not able to accomplish by myself.


I've browsed the forum to integrate suggestion, and my code seems to work fine but the camera does not start and AR content (in my index.html etc. is not displayed, except for the alert tI've added to test in imageontarget.js - so the AR world is loaded without being displayed).


Can anyone provide a brief doc to create a very basical 1-view app (iOS, JS) in order to launch architect World in order to exploit the huge potential of Wikitude SDK?


really thanks,


Ricc

Hi Ricc,


Is this happening with the sample app or in your own app? If it happens with your own app, does the sample app work on your device? If the sample app is working as expected, please start with analyzing the code, playing around with it to see what effects changes have and have a detailed look at the documentation together with the sample app.


Thx and greetings

Nicola


Login or Signup to post a comment