Skip to content

Commit b1b15f6

Browse files
author
Fu Lili
committed
增加主动通知iOS回调的方法
1 parent b683fbb commit b1b15f6

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/sensorsdata.full.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2358,8 +2358,20 @@ saEvent.send = function(p, callback) {
23582358
window.sensorsdata_app_js_bridge_call_js = function(data){
23592359
setAppInfo(data);
23602360
};
2361+
// 通知iOS
2362+
function calliOS() {
2363+
if (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream) {
2364+
var iframe = document.createElement("iframe");
2365+
iframe.setAttribute("src", "sensorsanalytics://getAppInfo");
2366+
document.documentElement.appendChild(iframe);
2367+
iframe.parentNode.removeChild(iframe);
2368+
iframe = null;
2369+
}
2370+
}
23612371
sd.getAppStatus = function(func){
2362-
//先获取能直接取到的安卓,ios是异步的不需要操作
2372+
// 通知iOS触发回调
2373+
calliOS();
2374+
//先获取能直接取到的安卓
23632375
getAndroid();
23642376
// 不传参数,直接返回数据
23652377
if(!func){

0 commit comments

Comments
 (0)