Using publisher.js with iOS webview ( or Safari in Mac) gives TypeError

nvineeth
<!DOCTYPE html>




body p span{
font-family:monospace;
font-weight:bold;
}





KiteConnect.ready(function() {
kite = new KiteConnect("");
kite.add({
"exchange": "NSE",
"tradingsymbol": "INFY",
"quantity": 5,
"transaction_type": "BUY",
"order_type": "MARKET"
});
kite.renderButton("#kite-holder");
document.getElementById("kite-holder").lastChild.click();
kite.finished(function(status, request_token) {
})
})





This is the sample code (please replace test client id) ran in a WebView in an iOS app (Swift 3). After the login publisher.js gives an error. The issue can be reproduced on Safari Browser (Mac or iPhone WebView).

Errors : TypeError: undefined is not an object (evaluating 'this.win.document') - publisher.js : 24
Errors : TypeError: undefined is not an object (evaluating 'a.win.close') - publisher.js : 19
  • nvineeth
    nvineeth edited March 2017
    doctype html
    html
    head
    title
    |
    style.
    body p span{
    font-family:monospace;
    font-weight:bold;
    }
    |
    body(style='margin:0px;padding:0px;overflow:hidden')
    p#kite-holder(style='margin-top: 100px;')
    |
    script(src='https://kite.trade/publisher.js?v=1')
    |
    script.
    KiteConnect.ready(function() {
    kite = new KiteConnect("");
    kite.add({
    "exchange": "NSE",
    "tradingsymbol": "INFY",
    "quantity": 5,
    "transaction_type": "BUY",
    "order_type": "MARKET"
    });
    kite.renderButton("#kite-holder");
    document.getElementById("kite-holder").lastChild.click();
    kite.finished(function(status, request_token) {
    })
    })


    This is the jade file as html attributes are removed while posting.
  • nvineeth
    Also, in iOS Web View, publisher.js redirects to login page on successful login.
Sign In or Register to comment.