移動端開發之APP訊息推送

來源:互聯網
上載者:User

標籤:移動開發 app js

有這樣一種情境,當你在手機APP上輸入你的資訊,會自動跳出一個彈窗,表示某任務已執行。最簡單的一個例子就是當你輸入手機號,點擊擷取驗證碼的時候,就會跳出一個對話方塊,說“驗證碼已發送到手機,請注意查收”,這些都是如何?的。

就以我參與開發的一款行動報表FineReport為例,講解一下如何開發手動推送APP訊息。

這個APP裡有這樣一個應用,它是可以實現在用戶端填報錄入資料,然後資料上傳到資料庫中的這樣一個功能,也就是所謂的移動化辦公,這在企業辦公方面用得比較多。當資料錄入系統成功後,會自動發送訊息至APP提示資料已更新。

此功能的實現就是在資料錄入成功的事件中添加js,使用ajax發送訊息請求

FR.ajax({url:‘http://192.168.1.120:8033/WebReport/ReportServer?cmd=send_messages&op=fs_mobile_main‘,type: ‘POST‘, data: {user:‘sunlin‘,text:‘填報成功,模板A有資料更新‘,url:‘http://192.168.1.120:8033/WebReport/ReportServer?reportlet=app.cpt&op=write‘,title:‘app‘},success: function(msg){ alert( "提示" + msg ); } });

user:接收訊息的人,可以是多個,多個使用者之間用逗號分割,如“A,B” (必填)

text:訊息內容 (選填)

url:開啟地址(選填),在點擊訊息之後 進入app開啟的地址

title: 開啟地址的頁面標題(選填)

舉例

例子1、推送純文字訊息

在填報的模板,增加填報成功事件,範例程式碼如下:

FR.ajax({url:‘http://192.168.1.120:8033/WebReport/ReportServer?cmd=send_messages&op=fs_mobile_main‘,type: ‘POST‘, data: {user:‘sunlin‘, text:‘填報成功,模板A有資料更新‘},success: function(msg){ alert( "提示" + msg ); } });

650) this.width=650;" src="http://img.blog.csdn.net/20160729133824297" style="border:none;color:rgb(54,46,43);font-family:Arial;font-size:14px;line-height:26px;white-space:normal;background-color:rgb(255,255,255);" />
650) this.width=650;" src="http://img.blog.csdn.net/20160729133850829" style="border:none;color:rgb(54,46,43);font-family:Arial;font-size:14px;line-height:26px;white-space:normal;background-color:rgb(255,255,255);" />

例2、點擊訊息後,進入app,並且開啟地址頁面

在後台填報的模板,增加填報成功事件,範例程式碼如下:

FR.ajax({url:‘http://192.168.1.120:8033/WebReport/ReportServer?cmd=send_messages&op=fs_mobile_main‘,type: ‘POST‘, data: {user:‘sunlin‘, text:‘填報成功,模板A有資料更新‘,url:‘http://192.168.1.120:8033/WebReport/ReportServer?reportlet=app.cpt&op=write‘,title:‘app‘},success: function(msg){ alert( "提示" + msg ); } });

650) this.width=650;" src="http://img.blog.csdn.net/20160729133931127" style="border:none;color:rgb(54,46,43);font-family:Arial;font-size:14px;line-height:26px;white-space:normal;background-color:rgb(255,255,255);" />
650) this.width=650;" src="http://img.blog.csdn.net/20160729134734895" style="border:none;color:rgb(54,46,43);font-family:Arial;font-size:14px;line-height:26px;white-space:normal;background-color:rgb(255,255,255);" />


移動端開發之APP訊息推送

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.