2017-03-05 144 views
3

我是新流星。流星:當應用程序關閉時,推送通知:推動Android

現在我正在嘗試與科爾多瓦集成,主要是使用raix的推送通知:推送流星插件。

應用程序在後臺運行時收到簡單通知,儘管我沒有設法接收通知中的圖像。

當應用程序完全關閉時發生主要問題,因爲它無法接收通知,並且服務器不會丟失任何錯誤消息。

該應用程序部署在Heroku服務器中。

%%%%%%%%%%%%%%%%%%%%%% 
% mobile-config.js %% 
%%%%%%%%%%%%%%%%%%%%%% 

App.configurePlugin('phonegap-plugin-push', { 
    SENDER_ID: XXXXXXXXXXX 
}); 


%%%%%%%%%%%%%%%%%% 
% client/main.js % 
%%%%%%%%%%%%%%%%%% 

import { Template } from 'meteor/templating'; 
import { ReactiveVar } from 'meteor/reactive-var'; 

import './main.html'; 

Push.Configure({ 
android: { 
    senderID: XXXXXXXXXXX, 
    alert: true, 
    badge: true, 
    sound: true, 
    vibrate: true, 
    clearNotifications: true 
    // icon: '', 
    // iconColor: '' 
}, 
}); 

Template.hello.onCreated(function helloOnCreated() { 
// counter starts at 0 
this.counter = new ReactiveVar(0); 
}); 

Template.hello.helpers({ 
    counter() { 
    return Template.instance().counter.get(); 
    }, 
}); 

Template.hello.events({ 
'click button'(event, instance) { 
    // increment the counter when button is clicked 
    instance.counter.set(instance.counter.get() + 1); 
}, 

}); 

%%%%%%%%%%%%%%%%%% 
% server/main.js % 
%%%%%%%%%%%%%%%%%% 

import { Meteor } from 'meteor/meteor'; 

Meteor.startup(() => { 
// code to run on server at startup 

Push.Configure({ 
    gcm: { 
    apiKey: 'XXXXXXXXXXXXXXXXXXXXXX', 
    }, 
    production: true, 
}); 

}); 

Meteor.methods({ 
sendPush: function() { 
    return Push.send({ 
    from: 'Test', 
     title:'Greetings', 
     text:'Hello world!', 
     badge: 3, 
     query: {}, 
    }); 
    }, 
}); 

的mesagge在服務器外殼發送

> Meteor.call('sendPush'); 

我使用的下一個版本:

// [email protected] 
// raix:[email protected] 
// [email protected] 
// [email protected] 

我不明白是什麼問題,我花了很多時間試圖找到解決方案。任何幫助將受到歡迎。

+0

面臨類似問題。你能解決它嗎? – user3807691

回答

2

raix:push通知只能在服務器和客戶端應用程序正在運行 不能收到任何raix:push推送通知,如果你的手機應用程序沒有運行。在raix:push中,通過在服務器和客戶端上運行的Meteor方法生成和處理通知。這就是爲什麼你需要你的客戶端應用程序能夠處理通知。如果您需要在應用程序處於脫機狀態時正常工作的通知機制,則應使用推送通知服務,如Amazon SNSOneSignalPushwoosh等。

相關問題