0

푸시 알림을 탭하여 내 앱이 열렸는지 확인하는 가장 좋은 방법을 결정하려고합니다. 나는 이것을 할 다른 방법을 제안하는 몇 가지 다른 기사를 온라인으로 발견했지만, 아무도 애플 리케이션 플랫폼과 상태에 걸쳐 일관된 방식으로 작동하지 않는 것 같습니다.Appcelerator 앱이 푸시 알림에서 열렸는지 확인

공식 Appcelerator 방법이 있습니까?

답변

0

예, 공식적인 방법이 있습니다.

if (Ti.Platform.getOsname() !== 'android') { 

    // Wait for user settings to be registered before registering for push notifications 
    Ti.App.iOS.addEventListener('usernotificationsettings', function registerForPush() { 

     // Remove event listener once registered for push notifications 
     Ti.App.iOS.removeEventListener('usernotificationsettings', registerForPush); 

     Ti.Network.registerForPushNotifications({ 
      success: deviceTokenSuccess, 
      error: deviceTokenError, 
      callback: receivePush 
     }); 
    }); 

    // Register notification types to use 
    Ti.App.iOS.registerUserNotificationSettings({ 
     types: [ 
      Ti.App.iOS.USER_NOTIFICATION_TYPE_ALERT, 
      Ti.App.iOS.USER_NOTIFICATION_TYPE_SOUND, 
      Ti.App.iOS.USER_NOTIFICATION_TYPE_BADGE 
     ] 
    }); 
} 
// For Android 
else { 
    var CloudPush = require('ti.cloudpush'); 
    var deviceToken = null; 

// Initialize the module 
    CloudPush.retrieveDeviceToken({ 
     success: deviceTokenSuccess, 
     error: deviceTokenError 
    }); 

    // Process incoming push notifications 
    CloudPush.addEventListener('callback', function (evt) { 
     receivePush(evt); 
    }); 
} 

// Process incoming push notifications 
function receivePush(e) { 
    // alert(e.data); 
} 
관련 문제