6

मैं वर्तमान में आयनिक/एनजीकोर्डोवा का उपयोग कर एंड्रॉइड एप्लिकेशन बना रहा हूं। मैं पुश अधिसूचनाओं को लागू करने के बिंदु पर हूं। मैंने पुश अधिसूचनाओं को एक सेवा के रूप में लागू किया है जिसे app.run(function(){..}) चरण में इंजेक्शन दिया गया है। पंजीकरण भाग काम करता है और मुझे regid युक्त कॉलबैक प्राप्त होता है। साथ ही, जब आवेदन सक्रिय स्थिति में होता है, तो ईवेंट उठाया जाता है और अधिसूचना प्राप्त होती है।एनजी कॉर्डोवा/आयनिक पुश नोटिफिकेशन जब पृष्ठभूमि पृष्ठभूमि में है

मेरी समस्या यह है कि जब एप्लिकेशन पृष्ठभूमि में जाता है, अधिसूचनाएं बिल्कुल प्राप्त नहीं होती हैं। मैं उम्मीद करता हूं कि ऐप नहीं चल रहा है या कुछ समान होने पर एक स्थानीय अधिसूचना उठाई जाएगी, लेकिन बिल्कुल कुछ भी नहीं होता है, जो अजीब है।

मैंने समाधान की तलाश में पिछले कुछ दिनों से वेब का पता लगाया है, लेकिन मुझे यह पता लगाने में असमर्थ रहा है कि मुझे किस तरह का संकेत मिलता है कि यह सिर्फ काम करना चाहिए। यह आदेश सूचनाएं देने के लिए में मदद करता है, मैं एक .net आवेदन के माध्यम से PushSharp उपयोग कर रहा हूँ तो

निम्नलिखित मेरे ऐप

app.factory('notificationService', ['$cordovaPush', function($cordovaPush){ 

    var dataFactory = {}; 

    // 
    // When the device is ready and this service has been plumbed in... 
    document.addEventListener("deviceready", function(){ 

     console.log("initializing push notifications..."); 

     _register(); 

    }, false); 


    // 
    // Registers the device for push notifications... 
    var _register = function(){ 

     var config = {}; 

     if (device.platform == 'android' || device.platform == 'Android' || device.platform == "amazon-fireos"){ 

      // TODO: centralise this value as it can change... 
      config = { 
       senderID: "448168747432", 
       ecb: "onNotificationGCM" 
      }; 

     }else { 
      // iOS 
      config = { 
       "badge":"true", 
       "sound":"true", 
       "alert":"true" 
      }; 

      // Can add the following property to the config object to raise a callback with the information if need be... 
      // "ecb": "onNotificationRegisterAPN" 
     } 

     $cordovaPush.register(config).then(function(result){ 

        // 
        // Typically returns "ok" for android and devicetoken for iOS 
      console.log(result); 

     }); 
    }; 

    window.onNotificationGCM = function(result){ 

     console.log(result); 

     /* 
     I get called when the app is in the foreground, but nothing happens when the app is in the background. 
     */ 

    }; 

    dataFactory.register = _register; 

    return dataFactory; 
}]); 

अंदर मेरे notificationService.js है। किसी भी तरह की सहायता का स्वागत किया जाएगा।

अद्यतन: मैं निम्नलिखित चौखटे/libs उपयोग कर रहा हूँ:

  • आयोनिक फ्रेमवर्क 1.2.14-beta6
  • Cordova 4.2.0
  • PushPlugin

उत्तर

3

किसी के लिए अन्यथा जो मेरे पास कुछ दिनों के लिए अपने बालों को खींच रहा है, समाधान वास्तव में सरल था ... मुझे अपने पुष्शर्प क्यूई नोटिफिकेशन आवश्यकता में दो गुण गायब थे सेंट। https://github.com/Redth/PushSharp#sample-code

push.QueueNotification(new GcmNotification().ForDeviceRegistrationId("DEVICE-REGISTRATION-ID-HERE").WithJson("{\"alert\":\"Hello World!\",\"badge\":7,\"sound\":\"sound.caf\"}")); 

आवश्यकताओं को अपडेट करने की याद आ रही गुण जोड़ने के लिए:: तो उदाहरण PushSharp GitHub रेपो यहाँ पर दिए गए का उपयोग कर

push.QueueNotification(new GcmNotification().ForDeviceRegistrationId("DEVICE REGISTRATION ID HERE") 
         .WithJson(@"{""alert"":""This is the future"",""badge"":7,""sound"":""sound.caf"",""title"":""Status Bar title"",""message"":""Some text you want to display to the user""}")); 

अन्यथा यदि आपका ऐप्स Cordova और उसके नहीं का उपयोग कर विकसित किया जाना होता है वर्तमान में अग्रभूमि में, कुछ नहीं, दोहराना कुछ भी नहीं होगा।

सही दिशा में मुझे यहाँ ओर इशारा करते हुए के लिए PushPlugin पर अपने टिप्पणी के साथ gdelavald करने के लिए मेरी टोपी टिप:

https://github.com/phonegap-build/PushPlugin/issues/212

संबंधित मुद्दे