2017-12-22 11 views
0

T에 대한 응답 네이티브 푸시 알림 설명서 (https://github.com/zo0r/react-native-push-notification)에 대한 가이드를 따라 왔지만 간단한 알림을 생성 할 수 없습니다. 내 휴대 전화에 응용 프로그램을로드하십시오. 대신 XCode 콘솔에서 알림을 볼 수 있습니다. 그렇지 않으면 오류가 없습니다.네이티브 푸시 알림이 XCode 콘솔에 표시되지만 장치에는 표시되지 않습니다.

var PushNotification = require('react-native-push-notification'); 

PushNotification.configure({ 

    // (optional) Called when Token is generated (iOS and Android) 
    onRegister: function(token) { 
     console.log('TOKEN:', token); 
    }, 

    // (required) Called when a remote or local notification is opened or received 
    onNotification: function(notification) { 
     console.log('NOTIFICATION:', notification); 

     // process the notification 

     // required on iOS only (see fetchCompletionHandler docs: https://facebook.github.io/react-native/docs/pushnotificationios.html) 
     notification.finish(PushNotificationIOS.FetchResult.NoData); 
    }, 

    // ANDROID ONLY: GCM Sender ID (optional - not required for local notifications, but is need to receive remote push notifications) 
    senderID: "YOUR GCM SENDER ID", 

    // IOS ONLY (optional): default: all - Permissions to register. 
    permissions: { 
     alert: true, 
     badge: true, 
     sound: true 
    }, 

    // Should the initial notification be popped automatically 
    // default: true 
    popInitialNotification: true, 

    /** 
     * (optional) default: true 
     * - Specified if permissions (ios) and token (android and ios) will requested or not, 
     * - if not, you must call PushNotificationsHandler.requestPermissions() later 
     */ 
    requestPermissions: true, 
}); 

export default class PostList extends Component<{}> 
{ 
    componentDidMount() { 
     PushNotification.localNotification({ 
       /* Android Only Properties */ 
       id: '0', // (optional) Valid unique 32 bit integer specified as string. default: Autogenerated Unique ID 
       ticker: "My Notification Ticker", // (optional) 
       autoCancel: true, // (optional) default: true 
       largeIcon: "ic_launcher", // (optional) default: "ic_launcher" 
       smallIcon: "ic_notification", // (optional) default: "ic_notification" with fallback for "ic_launcher" 
       bigText: "My big text that will be shown when notification is expanded", // (optional) default: "message" prop 
       subText: "This is a subText", // (optional) default: none 
       color: "red", // (optional) default: system default 
       vibrate: true, // (optional) default: true 
       vibration: 300, // vibration length in milliseconds, ignored if vibrate=false, default: 1000 
       tag: 'some_tag', // (optional) add tag to message 
       group: "group", // (optional) add group to message 
       ongoing: false, // (optional) set whether this is an "ongoing" notification 

       /* iOS and Android properties */ 
       title: "My Notification Title", // (optional, for iOS this is only used in apple watch, the title will be the app name on other iOS devices) 
       message: "My Notification Message", // (required) 
       playSound: false, // (optional) default: true 
       soundName: 'default', // (optional) Sound to play when the notification is shown. Value of 'default' plays the default sound. It can be set to a custom sound such as 'android.resource://com.xyz/raw/my_sound'. It will look for the 'my_sound' audio file in 'res/raw' directory and play it. default: 'default' (default sound is played) 
       number: '10', // (optional) Valid 32 bit integer specified as string. default: none (Cannot be zero) 
       repeatType: 'day', // (Android only) Repeating interval. Could be one of `week`, `day`, `hour`, `minute, `time`. If specified as time, it should be accompanied by one more parameter 'repeatTime` which should the number of milliseconds between each interval 
       actions: '["Yes", "No"]', // (Android only) See the doc for notification actions to know more 
      }); 
    } 
} 
+0

권한을 확인 했습니까? –

+0

정확한 iOS 버전은 무엇입니까? – Honey

+0

iOS 11.2.1 및 휴대 전화가 권한을 요청할 때 "허용"을 눌렀습니다. – Colin

답변

0

알림 시스템을 사용하려면 내 Apple 개발자 계정이 유료 구독자 계정이어야한다는 것이 문제가되었습니다. 나는 그것을 깨닫지 못했고 어떠한 이유로 든 오류가 발생하지 않았다. 계정을 업데이트하면 알림이 작동하기 시작했습니다.