私がやろうとしているのは、iOS PhoneGap/Cordova アプリケーションを作成することです。それが行う唯一のことは、外部 URL をロードし、PushNotifications を有効にすることです。
両方を別々に行うことはできますが、両方を一緒に行うことはできないようです。
PushNotifications の場合、私はプラグインを使用していますが、これはうまく機能しているようです。
ただし、 index.html から外部 URL を開こうとすると、PushNotification が機能しません。
このチュートリアルを使用して Push iOS PhoneGap/Cordova Pushを有効にしています。
そして、サンプルコードをダウンロードした後、次のようなものを使用しようとしています:
<!DOCTYPE html>
<html>
<head>
<title>InAppBrowser.addEventListener Example</title>
<script src="cordova-2.5.0.js"></script>
<script src="js/PushNotification.js"></script>
<script src="js/index.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for Cordova to load
//
document.addEventListener("deviceready", onDeviceReady, false);
// Cordova is ready
//
function onDeviceReady() {
var ref = window.open('http://apache.org', '_blank', 'location=yes');
ref.addEventListener('loadstart', function() { alert('start: ' + event.url); });
ref.addEventListener('loadstop', function() { alert('stop: ' + event.url); });
ref.addEventListener('exit', function() { alert(event.type); });
}
</script>
</head>
<body>
</body>
</html>
プッシュを有効にするために必要なスクリプト index.js と pushnotifications.js を含めます。
しかし、URL の読み込みしか表示されず、プッシュが有効になっていません。
これを試すと、プッシュが有効になります:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name = "format-detection" content = "telephone=no"/>
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width;" />
<title>Push Notification Tester</title>
<link href="css/index.css" rel="stylesheet" />
</head>
<body>
<script src="cordova-2.5.0.js"></script>
<script src="js/PushNotification.js"></script>
<script src="js/index.js"></script>
<script type="text/javascript">
console.log("Test " + app);
app.initialize();
</script>
</body>
</html>
もちろん、この例では、私が望むように外部 URL を使用していません。では、このコードに外部 Url 関数を追加して、外部 URL とプッシュの両方を持たせるにはどうすればよいでしょうか?
何か案は?