0

ビデオ ギャラリーを表示する TVOS アプリを作成しましたが、これは正常に動作しますが、別の TVOS アプリから作成したこの TVOS アプリを呼び出せるようにする必要があります。これについてどうすればよいか、またはこれが可能かどうかはわかりません。基本的に、一番下にボタンがあり、クリックすると別の TVOS アプリが動的に読み込まれる TVOS アプリが 1 つ必要です。これを考える別の方法は、親アプリを子アプリのコンテナーにしたいということです。親アプリは、子アプリをロードする方法以外に子アプリの知識を持っていません。

何か助けはありますか?以下は私のコードです。


アプリ #2 (アプリ #1 で開く):

info.plist:

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>brightline123456</string>
</array>

AppDelegate.swift:

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, TVApplicationControllerDelegate {

var window: UIWindow?
var appController: TVApplicationController?
static let TVBaseURL = "http://localhost:9001/"
static let TVBootURL = "\(AppDelegate.TVBaseURL)js/application.js"

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    window = UIWindow(frame: UIScreen.mainScreen().bounds)

    // 1
    let appControllerContext = TVApplicationControllerContext()

    // 2
    guard let javaScriptURL = NSURL(string: AppDelegate.TVBootURL) else {
        fatalError("unable to create NSURL")
    }
    appControllerContext.javaScriptApplicationURL = javaScriptURL
    appControllerContext.launchOptions["BASEURL"] = AppDelegate.TVBaseURL

    // 3
    appController = TVApplicationController(context: appControllerContext, window: window, delegate: self)
    return true
  }

}

アプリケーション.js:

var resourceLoader;

App.onLaunch = function(options) {
// 2
var javascriptFiles = [
`${options.BASEURL}js/ResourceLoader.js`,
`${options.BASEURL}js/Presenter.js`
];

evaluateScripts(javascriptFiles, function(success) {
if(success) {
  // 3
  resourceLoader = new ResourceLoader(options.BASEURL);
   resourceLoader.loadResource(`${options.BASEURL}templates/RWDevConTemplate.xml.js`, function(resource) {
    var doc = Presenter.makeDocument(resource);
    doc.addEventListener("select", Presenter.load.bind(Presenter)); //add this line
    Presenter.pushDocument(doc);
  });
} else {
  var errorDoc = createAlert("Evaluate Scripts Error", "Error attempting to evaluate external JavaScript files.");
  navigationDocument.presentModal(errorDoc);
}
});
}

アプリ #1 (canOpenUrl を使用してアプリ #2 を開きます):

info.plist:

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>brightline123456</string>
        </array>
        <key>CFBundleTypeRole</key>
        <string></string>
        <key>CFBundleURLName</key>
        <string>com.brightline123456</string>
    </dict>
</array>

AppDelegate.swift:

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


func application(application: UIApplication, openURL:(NSURL), sourceApplication:(NSString), didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    let url  = NSURL(string: "brightline123456://"); // Change the URL with your URL Scheme
    if UIApplication.sharedApplication().canOpenURL(url!) == true
    {
        UIApplication.sharedApplication().openURL(url!)
    }

    // Override point for customization after application launch.
    window = UIWindow(frame: UIScreen.mainScreen().bounds)

    return true
}

}

4

1 に答える 1

-1

https://forums.developer.apple.com/message/7973#7973の別の投稿を見ると、

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>brightline123456</string>
</array>

発信者アプリ(あなたの場合はApp1)にいますか?

于 2016-10-28T00:24:39.593 に答える