小编new*_*eep的帖子

如何使用jsonp与node.js表达

我正在尝试用node.js制作三星智能电视应用程序.

在我的项目中,我想让我的应用程序与服务器PC通信.

根据许多网站,我可以用"jsonp"来做到这一点.

这是我找到的客户端代码.

<html>
<head>
    <title>jsonp test</title>
    <script src="http://code.jquery.com/jquery-1.6.2.min.js"></script>      
    <script type="text/javascript">
        $(function(){               
            $('#select_link').click(function(e){
                e.preventDefault();
                console.log('select_link clicked');

                function test(data){
                    return {"message":"ok"};
                }

                 $.ajax({
                    dataType: 'jsonp',
                    data: "data=yeah",                      
                    jsonp: 'callback',
                    url: 'http://172.20.10.3:3000/endpoint?callback=?',                     
                    success: function(data) {
                        console.log('success');
                        console.log(JSON.stringify(data));
                    }
                });
            });             
        });
    </script>
</head>
<body>
    <div id="select_div"><a href="#" id="select_link">Test</a></div>    
</body>
Run Code Online (Sandbox Code Playgroud)

而且,这是我找到的服务器端代码.

app.get('/endpoint', function(req, res){
var obj = {};
obj.title = 'title';
obj.data = 'data';

console.log('params: ' + JSON.stringify(req.params));
console.log('body: ' + JSON.stringify(req.body));
console.log('query: ' + JSON.stringify(req.query));

res.header('Content-type','application/json');
res.header('Charset','utf8');
res.send(req.query.callback + '('+ JSON.stringify(obj) …
Run Code Online (Sandbox Code Playgroud)

jsonp node.js express

19
推荐指数
2
解决办法
3万
查看次数

当应用程序未在 React-Native firebase 中运行时,如何设置通知声音

我试图在应用程序未在 IOS 中运行时让通知响起。

这是我的代码。

  this.notificationListener = firebase.notifications().onNotification((notification: Notification) => {

    // SET SYSTEM DEFAULT SOUND!
    notification.setSound("default");
    firebase.notifications().displayNotification(notification);

  });
Run Code Online (Sandbox Code Playgroud)

当应用程序处于后台或前台时(也许我可以说“应用程序正在运行”),通知会响起。

我应该使用其他监听器吗?或者我应该添加自己的铃声文件吗?

push-notification ios firebase react-native react-native-firebase

6
推荐指数
1
解决办法
9178
查看次数