0

앱이 백그라운드 모드가 아닌 경우 비활성 모드와 앱이 완전히 종료됩니다. 응용 프로그램의 위임 "didFinishLaunchingWithOption"메서드를 사용하여 모든 알림을 검색하는 방법보다 나는 그것에 대해 많이 검색했지만 아무것도 얻지 못했습니다. 도와주세요 .객관적인 C에서 didFinishLaunchingWithOption 응용 프로그램 메서드의 원격 알림을 검색하는 방법?

감사

+0

앱이 일시 중단 된 상태에 사용되는 방법 didFinishLaunchingWithOptions에서 감지 할 수 있습니다. pushnotification에서 데이터를 얻을 수 없습니다. 사용자가 데이터를 가져온 후에 알림을 누르거나 (또는) 클릭합니다. 사용 "didRecieveRemoteNotification" –

+0

괜찮아요 당신이 응용 프로그램 아이콘을 클릭하면 dofinishlaunchingwithOption 메서드에서 알림 데이터에 액세스 할 수없는 것보다, 응용 프로그램이 일시 중지 상태에 있다면 말을 의미합니다. ? –

+0

예, 사용자가받은 알림을 클릭하면 알림 데이터에 액세스합니다. –

답변

1

이 notifiaction

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
UILocalNotification *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey]; 
    if (notification) 
    { 


    } 
} 


-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken 
{ 
    NSString *token = [[[[deviceToken description] 
         stringByReplacingOccurrencesOfString:@"<"withString:@""] 
        stringByReplacingOccurrencesOfString:@">" withString:@""] 
        stringByReplacingOccurrencesOfString: @" " withString: @""]; 
    NSLog(@"Token:%@",token); 

} 

//app is forground this method will access 
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo 
{ 

} 
//need to on teh background fetch option in info plist 
//app is background state this below mthod will call while notification receives 
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler 
{ 
    NSLog(@"Background mode working%@",userInfo); 

    if([userInfo[@"aps"][@"content-available"] intValue]== 1) //it's the silent notification when recive preferences and text messages 
    { 
    } 
} 

//handling interactive notification 
    - (void)application:(UIApplication *)application handleActionWithIdentifier:(nullable NSString *)identifier forLocalNotification:(nonnull UILocalNotification *)notification completionHandler:(nonnull void (^)())completionHandler { 
    } 
+0

이 백그라운드 인출 메서드는 응용 프로그램이 종료되었을 때 알림 데이터를 가져올 수 있습니까? (일시 중지되었습니다.) –

+0

당신의 대답은 좋습니다. 나는 이것을 즉각적으로 시도 할 것입니다.하지만 저는이 방법이 앱의 일시 중지 상태에 대한 알림 데이터를 제공함을 알고 싶습니다. –

+0

백그라운드에서 알림 데이터를 얻을 수 있습니다. 배경은 앱을 종료하기 위해 홈 버튼을 누를 때를 의미합니다.일시 중지 상태는 홈 버튼을 두 번 클릭 한 다음 앱을 스 와이프하여 닫기 @Harry –

0

당신은 didFinishLaunchingWithOption 방법

let launchedFromRemoteNotification = launchOptions?[UIApplicationLaunchOptionsRemoteNotificationKey] != nil 
+0

당신은 나에게 객관적인 C의 예를 들어 줄 수 있고 나는 완전히 통보를 원합니다. –

0

에서이 작업을 수행 할 수 있습니다 당신은이 방법으로 didFinishLaunchingWithOption에서 알림을받을 수 있습니다

(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ 

    NSDictionary *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey]; 
    if (notification) { 
      NSLog(@"app recieved notification from remote%@",notification); 
    }else{ 
     NSLog(@"app did not recieve notification"); 
    } 
} 

가 당신을 도울 수도보십시오. 앱이 종료되고 다시 시작하는 경우

+0

알림을받은 후 앱 아이콘을 클릭 할 때 알림이 표시되지만 알림을받지 못합니다. –

+0

@HarrySaggu 알림 아이콘을 클릭하는 대신 알림을 클릭해야합니다. – Bhumi

+0

앱 아이콘 클릭시 알림 데이터를 가져 오는 방법입니다. –

0

, 당신은 원격 알림 통지에 원격 알림을 탭 사용자가 트레이 때문에 응용 프로그램이 실행되는 경우에만을 감지 할 수 있습니다.

당신은이 방법을 아래

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ 

    NSDictionary *notificationDict = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey]; 
    if (notificationDict) { 
     //Your App received a remote notification 
    }else{ 
     //Your App did not receive a remote notification 
    } 
} 
관련 문제