2015-11-30 6 views
5

मैं निम्नलिखित की आवश्यकता के लिए एक साफ समाधान बनाने के लिए कोशिश कर रहा हूँ करने के लिए लाने के लिए:Xamarin-एंड्रॉयड Mvvmcross - छप के साथ प्राप्त अधिसूचना शुरू एप्लिकेशन पर टैप करने या सामने

क) जब उपयोगकर्ता को कोई सूचना पर 'टैप करता है कि मेरा ऐप प्राप्त करता है और ऐप खुला है और/या पृष्ठभूमि में, ऐप को फ़ॉन्ट पर लाया जाएगा।

बी) जब उपयोगकर्ता अधिसूचना पर 'टैप' करता है और ऐप बंद हो जाता है, तो स्पलैशस्क्रीन दिखाता है और ऐप शुरू होता है जैसा कि सामान्य रूप से होता है।

मैं कोशिश कर रहा हूं लेकिन मुझे उपर्युक्त विकल्पों में से किसी एक के साथ सफलता मिली है, दोनों दुख की बात नहीं। यह मेरा कोड है:

public class SplashScreen : MvxSplashScreenActivity 

और

public class DashboardView : BaseMvxActivity 

अगर मैं "SplashScreen" का उपयोग के लिए PendingIntent के रूप में:

public void CreateNotification(string title, string desc, string pushUrl, string pushTitle) 
    { 
     var setupSingleton = MvxAndroidSetupSingleton.EnsureSingletonAvailable(ApplicationContext); 
     setupSingleton.EnsureInitialized(); 

     if (!string.IsNullOrWhiteSpace(pushUrl)) 
     { 
      var pushMessageParameterService = Mvx.Resolve<IPushMessageParameterService>(); 
      pushMessageParameterService.SetPushActionParameters(new PushActionParameters 
      { 
       UrlToShow = pushUrl, 
       ViewTitle = pushTitle 
      }); 
     } 

     var intent = new Intent(this, typeof(SplashScreen)); 
     intent.AddFlags(ActivityFlags.NewTask); 
     intent.SetAction(Intent.ActionMain); 
     intent.AddCategory(Intent.CategoryLauncher); 

     //var pendingIntent = PendingIntent.GetActivity(this, 0, intent, PendingIntentFlags.OneShot); 
     //var pendingIntent = PendingIntent.GetActivity(this, 0, intent, 0); 
     var pendingIntent = PendingIntent.GetActivity(this, 0, intent.SetFlags(ActivityFlags.BroughtToFront), PendingIntentFlags.CancelCurrent); 

     Uri alarmSound = RingtoneManager.GetDefaultUri(RingtoneType.Notification); 

     var notificationBuilder = new Notification.Builder(this) 
      .SetSmallIcon(Resource.Drawable.Icon) 
      .SetContentTitle(title) 
      .SetContentText(desc) 
      .SetAutoCancel(true) 
      .SetSound(alarmSound) 
      .SetContentIntent(pendingIntent); 

     var notificationManager = (NotificationManager)GetSystemService(Context.NotificationService); 
     Notification notification = notificationBuilder.Build(); 
     notification.Flags = NotificationFlags.ShowLights | NotificationFlags.AutoCancel; 

     notificationManager.Notify(0, notification); 
    } 

यह सरल रखने के लिए, मैं दो गतिविधियों मिल गया है अधिसूचना, और ऐप पृष्ठभूमि में पहले से ही शुरू/खुला/प्रारंभ है, यह स्प्लैशस्क्रीन पर लटकता है। एमवीवीएमक्रॉस लॉगिंग "व्यूमोडेल डैशबोर्ड व्यू मॉडेल दिखा रहा है" दिखाता है लेकिन वहां रुक जाता है। ऑनक्रेट, इनिट और स्टार्ट नहीं कहा जाता है। स्पलैश बस रहता है।

अगर मैं अधिसूचना के लिए लंबित इंटेंट के रूप में "डैशबोर्ड व्यू" का उपयोग करता हूं और ऐप बंद/सक्रिय नहीं है, तो मुझे बस स्टार्ट और कोई स्प्लैश स्क्रीन पर एक सफेद स्क्रीन दिखाई नहीं दे रही है।

मैं दोनों दुनिया के सर्वश्रेष्ठ होना चाहता हूं :)। तो जब पुश संदेश पर टैप करते हैं और ऐप खुला होता है, तो ऐप को सामने लाएं (यदि यह पहले से नहीं है)। और जब ऐप बंद हो जाता है, तो स्प्लैशस्क्रीन इत्यादि दिखाएं

मुझे आशा है कि मैंने अपना प्रश्न स्पष्ट कर दिया है।

अग्रिम में बहुत धन्यवाद।

+0

क्या आपने इसे प्रबंधित किया? मैं एक ही व्यवहार पर फंस गया हूँ। –

+0

यहां तक ​​कि मुझे भी एक ही समस्या का सामना करना पड़ रहा है .. – GvSharma

उत्तर

1

जब मैंने अपनी अधिसूचना के लिए MvxSplashScreenActivity का उपयोग करने का प्रयास किया तो यह उस स्क्रीन पर जम गया।

मैंने इसे मानक एमवीएक्सएक्टिविटी को इंगित किया और पर Activity विशेषता पर पृष्ठभूमि को स्वयं सेट किया। मेरी लंबित गतिविधि में ऑनक्रेट में मैंने असली इरादा शुरू किया है।

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