0

푸시 알림 기능이있는 Phonegap 3.0 앱을 만들었습니다. 나는 주로 블로그를 따라 갔다 here. Android 푸시가 완벽하게 작동합니다. 하지만 iOS에서 푸시 알림을받을 때 문제가 있습니다. 앱이 백그라운드에서 실행 중일 때 경고가 나타나고 사용자가이를 탭하면 앱이 열리고 메시지를 다시 얻기 위해 아약스 요청이 중지됩니다.Phonegap 3.0 푸시 알림에서 열면 iOS 앱이 멈 춥니 다.

그러나 앱이 실행 중일 때 포 그라운드 나 백그라운드에서 경고가 나타나지 않고 클릭 할 때 앱이 열리지 만 즉시 멈 춥니 다.

내 문제를 해결할 것이라고 생각한 비슷한 질문이 here입니다. 그러나, PhoneGap 3.0 프로젝트의 DidFinishLaunchingWithOptions() 코드는 질문의 코드처럼 보이지 않습니다. 다음과 같이 AppDelegate.m에 내 코드는 다음과 같습니다

- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions 
{ 
CGRect screenBounds = [[UIScreen mainScreen] bounds]; 

#if __has_feature(objc_arc) 
     self.window = [[UIWindow alloc] initWithFrame:screenBounds]; 
#else 
    self.window = [[[UIWindow alloc] initWithFrame:screenBounds] autorelease]; 
#endif 
    self.window.autoresizesSubviews = YES; 

#if __has_feature(objc_arc) 
     self.viewController = [[MainViewController alloc] init]; 
#else 
     self.viewController = [[[MainViewController alloc] init] autorelease]; 
#endif 

// Set your app's start page by setting the <content src='foo.html' /> tag in config.xml. 
// If necessary, uncomment the line below to override it. 
// self.viewController.startPage = @"index.html"; 

// NOTE: To customize the view's frame size (which defaults to full screen), override 
// [self.viewController viewWillAppear:] in your view controller. 

self.window.rootViewController = self.viewController; 
[self.window makeKeyAndVisible]; 

return YES; 
} 

나는 임 폰갭 3.0을 사용하기 때문에 아마도 didFinishLaunchingWithOptions에 대한 다른 코드에 대한 이유는 생각했다. 하지만 2.9에서 프로젝트를 만들었고 코드는 3.0과 같습니다. 같은 다른 questionis의 코드는 다음과 같습니다

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
//commented out because it makes the app crash at startup with local notification... 
/*NSArray *keyArray = [launchOptions allKeys]; 
if ([launchOptions objectForKey:[keyArray objectAtIndex:0]]!=nil) 
{ 
    NSURL *url = [launchOptions objectForKey:[keyArray objectAtIndex:0]]; 
    self.invokeString = [url absoluteString]; 
    NSLog(@"Mosa_fr_en-busi launchOptions = %@",url); 
}*/ 

return [super application:application didFinishLaunchingWithOptions:launchOptions]; 
} 

통지를 처리하는 자바 스크립트과 같이이다 :

onDeviceReady: function() { 

    var pushNotification = window.plugins.pushNotification; 
    if (window.device.platform == 'android' || window.device.platform == 'Android') { 
     pushNotification.register(app.successHandler, app.errorHandler,{"senderID":"475226855592","ecb":"app.onNotificationGCM"});       
    } 
    else{ 
     //so its apple 

     pushNotification.register(app.tokenHandler,app.errorHandler,{"badge":"true","sound":"true","alert":"true","ecb":"app.onNotificationAPN"}); 
    } 

}, 

과 :

onNotificationAPN: function(event) { 

    console.log(event.article_id); 

    if (event.article_id) 
    { 
     console.log('in event.article_id'); 
     window.location.hash = "article/"+event.article_id; 
     //localStorage.payload =// event.payload 
    } 

    var pushNotification = window.plugins.pushNotification; 
    if (event.alert) { 
     console.log('in event.alert'); 
     navigator.notification.alert(event.alert); 
    } 
    if (event.badge) { 
     console.log('in event.badge'); 
     console.log("Set badge on " + pushNotification); 
     pushNotification.setApplicationIconBadgeNumber(this.successHandler, event.badge); 
    } 
    if (event.sound) { 
     console.log('in event.sound'); 
     var snd = new Media(event.sound); 
     snd.play(); 
    } 


}, 

폰갭을 얻기 위해 실제로 가능 ios 푸시 알림이 완전히 작동합니까?

답변

0

설치가 끝나면 장치의 플러그를 뽑음으로써이를 해결했습니다. 여전히 xcode에 연결되어 있으면 두 번째 열 때 앱이 멈추는 원인이되었습니다.

관련 문제