Search code examples
androidiospush-notificationapple-push-notificationsandroid-notifications

Track push notifications and log them


For a project I’d like to track some specific iOS/Android apps and log their Pushes into my db.

I’m advanced with web scraping and db logging, but I have no idea how to extract information about new pushes from iOS/Android.

What would be the best/easiest way to do so?


Solution

  • This is what i have used to track push notification :

    public class TrackNotification extends NotificationListenerService {
    
    
    @Override
    public void onNotificationRemoved(StatusBarNotification sbn) {
        super.onNotificationRemoved(sbn);
    
        //your code stuff
    }
    
    @Override
    public void onNotificationPosted(StatusBarNotification sbn) {
        super.onNotificationPosted(sbn);
    
        //your code stuff
    }
    

    }

    In manifest :

     <service android:name=".Test"
            android:label="Test"
            android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
            <intent-filter>
                <action android:name="android.service.notification.NotificationListenerService" />
            </intent-filter>
        </service>