【发布时间】:2017-12-01 12:33:06
【问题描述】:
我正在使用以下代码向设备发送推送通知。
var nTitle = "New message from " + $rootScope.clients_firstName;
var to = "DeviceToken is here";
var notification = {
'title': nTitle,
//'body': 'Click here to more details...',
'icon': 'firebase-logo.png',
'click_action': 'openapp'
};
var key = 'your key';
fetch('https://fcm.googleapis.com/fcm/send', {
'method': 'POST',
'headers': {
'Authorization': 'key=' + key,
'Content-Type': 'application/json'
},
'body': JSON.stringify({
'notification': data,
'to': to
})
}).then(function(response) {
//console.log("res ", response);
}).catch(function(error) {
console.error("err ", error);
});
推送通知在设备上成功发送。
但是当我点击通知时,应该打开特定页面。
例如'click_action' : 'openapp/somepage'
那么当我点击 pushnotification 时,'somepage' 应该是打开的。
AndroidManifest.xml
<activity android:name="MainActivity" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="openapp" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
我的项目结构
--platforms
--plugins
--www
--app
--about
--about.html
--about.ctrl.js
--product
--product.html
--product.ctrl.js
--css
--js
--lib
index.html
如果我点击通知并想打开产品或关于页面,那我该怎么办?
这里有什么问题?请告诉我正确的解决方案。
【问题讨论】:
标签: android firebase ionic-framework