2011-12-15 14 views
8

मैं एक पर्यावरण (एडोब एयर) में एम्बेडेड हूं जहां मैं ओवरराइड नहीं कर सकता FinishLaunchingWithOptions। क्या उन विकल्पों को पाने का कोई और तरीका है? क्या वे कहीं कुछ वैश्विक चर में संग्रहीत हैं? या क्या किसी को पता है कि एआईआर में उन विकल्पों को कैसे प्राप्त किया जाए?ओवरराइड किए बिना लॉन्च विकल्प प्राप्त करें FinishLaunchingWithOptions:

मुझे ऐप्पल पुश अधिसूचना सेवा (एपीएनएस) के लिए इसकी आवश्यकता है।

+0

कोई किस्मत चॉन? – Sanniv

+0

मुझे लगता है कि आपको इसमें देखना चाहिए, मेरे पास एक बार समय होगा: http://www.tinytimgames.com/2011/09/01/unity-plugins-and-uiapplicationdidfinishlaunchingnotifcation/ – Michiel

+0

मुझे यह जोड़ना चाहिए कि आपको बनाना है काम करने के लिए एक एएनई (एयर मूल विस्तार)। http://www.adobe.com/devnet/air/native-extensions-for-air.html – Michiel

उत्तर

11

मिचिल लिंक (http://www.tinytimgames.com/2011/09/01/unity-plugins-and-uiapplicationdidfinishlaunchingnotifcation/) लिंक के पथ के बाद, आप एक कक्षा बना सकते हैं जो init विधि UIAplplicationDidFinishLaunchingNotification कुंजी के लिए एक पर्यवेक्षक जोड़ता है। जब पर्यवेक्षक विधि निष्पादित की जाती है, तो लॉन्चऑप्शन अधिसूचना के उपयोगकर्ता इन्फ्लो में निहित होगा। मैं स्थानीय सूचनाओं के साथ इस कर रहा था इसलिए यह मेरी कक्षा के कार्यान्वयन था:

static BOOL _launchedWithNotification = NO; 
static UILocalNotification *_localNotification = nil; 

@implementation NotificationChecker 

+ (void)load 
{ 
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(createNotificationChecker:) 
       name:@"UIApplicationDidFinishLaunchingNotification" object:nil]; 

} 

+ (void)createNotificationChecker:(NSNotification *)notification 
{ 
    NSDictionary *launchOptions = [notification userInfo] ; 

    // This code will be called immediately after application:didFinishLaunchingWithOptions:.  
    UILocalNotification *localNotification = [launchOptions objectForKey: @"UIApplicationLaunchOptionsLocalNotificationKey"]; 
    if (localNotification) 
    { 
     _launchedWithNotification = YES; 
     _localNotification = localNotification; 
    } 
    else 
    { 
     _launchedWithNotification = NO; 
    } 
} 

+(BOOL) applicationWasLaunchedWithNotification 
{ 
    return _launchedWithNotification; 
} 

+(UILocalNotification*) getLocalNotification 
{ 
    return _localNotification; 
} 

@end 

फिर जब अपने एक्सटेंशन संदर्भ आरंभ नहीं हो जाता मैं NotificationChecker वर्ग की जाँच देखने के लिए कि आवेदन एक अधिसूचना के साथ शुरू किया गया था।

BOOL appLaunchedWithNotification = [NotificationChecker applicationWasLaunchedWithNotification]; 
if(appLaunchedWithNotification) 
{ 
    [UIApplication sharedApplication].applicationIconBadgeNumber = 0; 

    UILocalNotification *notification = [NotificationChecker getLocalNotification]; 
    NSString *type = [notification.userInfo objectForKey:@"type"]; 

    FREDispatchStatusEventAsync(context, (uint8_t*)[@"notificationSelected" UTF8String], (uint8_t*)[type UTF8String]); 
} 

आशा है कि किसी की मदद करें!

+1

मैं अंत में यह करने के लिए चारों ओर मिल गया और मैं इस काम को एक आकर्षण की तरह पुष्टि करता हूं। – Michiel

+0

ग्रेट कोड !! इस छोटी सी टिप के लिए धन्यवाद ढेर !! – Michael

+0

'[अधिसूचना userInfo] 'मेरे लिए एक खाली शब्दकोश है = [' count == 0' – grisevg

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