菜鸟教程小白 发表于 2022-12-12 13:18:28

ios - iOS Ionic 应用程序中的链接未立即打开


                                            <p><p>我的应用程序的一个 View 中有几个链接:</p>

<ol>
<li>分享</li>
<li>添加到日历</li>
<li>打开外部链接</li>
</ol>

<p>在我用来测试应用程序的 iPhone 上,1 和 2 工作,但只有当我按下主页按钮然后返回应用程序时,才会出现共享/日历对话框。谁能建议可能导致这种情况的原因?我什至不知道在哪里看。</p>

<p>外部链接使用 window.open(url, "_system") 因为我无法让常规类型的链接在模拟器中工作。我可能会切换回常规的 HTML 链接,因为另一个链接能够在测试 iPhone 上工作。使用 iOS 在手机浏览器中打开链接的建议方法是什么?</p>

<p>代码大致如下。</p>

<p></p><div class="snippet"data-lang="js"data-hide="false"data-console="true"data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>.controller(&#39;WCtrl&#39;, function ($scope, $stateParams, $sce) {
// ...
$scope.doShare = function () {
    var options = {
      message: &#39;Message here&#39;,
      subject: &#39;Event shared&#39;
    };
    var onSuccess = function (result) {
      console.log(&#39;Share successful.&#39;);
    };
    var onError = function (msg) {
      console.log(&#39;Sharing failed with message: &#39; + msg);
    }
    window.plugins.socialsharing.shareWithOptions(options, onSuccess, onError);
};
$scope.doCalAdd = function () {
    var onSuccess = function (result) {
      console.log(&#39;Add to calendar successful.&#39;);
    };
    var onError = function (msg) {
      console.log(&#39;Add to calendar failed with message: &#39; + msg);
    }
    // ...
    window.plugins.calendar.createEventInteractively(
      title,
      location,
      notes,
      starttime,
      endtime,
      onSuccess,
      onError);
};
$scope.doTicketsOpen = function () {
    var url = w.ticketing;
    window.open(url, &#39;_system&#39;);
};
})</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;ion-view class=&#34;item-text-wrap&#34; view-title=&#34;Event Details&#34;&gt;
&lt;ion-content class=&#34;has-footer&#34;&gt;
    &lt;!-- ... --&gt;
&lt;/ion-content&gt;
&lt;ion-footer-bar&gt;
    &lt;div class=&#34;button-bar&#34;&gt;
      &lt;div class=&#34;button icon ion-share&#34; ng-click=&#34;doShare();&#34;&gt;Share&lt;/div&gt;
      &lt;div class=&#34;button icon ion-calendar&#34; ng-click=&#34;doCalAdd();&#34;&gt;Calendar&lt;/div&gt;
      &lt;div class=&#34;button icon ion-link&#34; ng-click=&#34;doTicketsOpen();&#34;&gt;Ticketing&lt;/div&gt;
    &lt;/div&gt;
&lt;/ion-footer-bar&gt;
&lt;/ion-view&gt;</code></pre>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>您必须在 <code>index 的 <code>Content-Security-Policy</code> 元标记的 <code>default-src</code> 中添加 <code>gap:</code> .html</code>.</p>

<p>这是因为在 iOS 10 上,Apple 对 CSP 的要求更加严格,而 <code>*</code> 并未涵盖某些内容</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - iOS Ionic 应用程序中的链接未立即打开,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/43326912/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/43326912/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - iOS Ionic 应用程序中的链接未立即打开