@@ -40,36 +40,37 @@ private void handlePushRegistration(Context context, Intent intent) {
40
40
}
41
41
42
42
private void handlePushReceived (Context context , Intent intent ) {
43
- Context appContext = context . getApplicationContext ();
44
-
45
- PackageManager packageManager = appContext .getPackageManager ();
46
- Intent packageIntent = packageManager .getLaunchIntentForPackage (appContext .getPackageName ());
47
- ComponentName componentPackageName = packageIntent .getComponent ();
48
- String mainClassName = componentPackageName .getClassName ();
49
- Class mainClass = null ;
50
- try {
51
- mainClass = Class .forName (mainClassName );
52
- } catch (ClassNotFoundException e ) {
53
- e .printStackTrace ();
54
- }
43
+ if ( intent . hasExtra ( IterableConstants . ITERABLE_DATA_KEY )) {
44
+ Context appContext = context . getApplicationContext ();
45
+ PackageManager packageManager = appContext .getPackageManager ();
46
+ Intent packageIntent = packageManager .getLaunchIntentForPackage (appContext .getPackageName ());
47
+ ComponentName componentPackageName = packageIntent .getComponent ();
48
+ String mainClassName = componentPackageName .getClassName ();
49
+ Class mainClass = null ;
50
+ try {
51
+ mainClass = Class .forName (mainClassName );
52
+ } catch (ClassNotFoundException e ) {
53
+ e .printStackTrace ();
54
+ }
55
55
56
- int iconId = appContext .getResources ().getIdentifier (
57
- IterableApi .getNotificationIcon (context ),
58
- "drawable" ,
59
- appContext .getPackageName ());
56
+ int iconId = appContext .getResources ().getIdentifier (
57
+ IterableApi .getNotificationIcon (context ),
58
+ "drawable" ,
59
+ appContext .getPackageName ());
60
60
61
- if (iconId == 0 ) {
62
- iconId = appContext .getApplicationInfo ().icon ;
63
- if (iconId != 0 ){
64
- Log .d (TAG , "No Notification Icon defined - defaulting to app icon" );
65
- } else {
66
- Log .w (TAG , "No Notification Icon defined - push notifications will not be displayed" );
61
+ if (iconId == 0 ) {
62
+ iconId = appContext .getApplicationInfo ().icon ;
63
+ if (iconId != 0 ) {
64
+ Log .d (TAG , "No Notification Icon defined - defaulting to app icon" );
65
+ } else {
66
+ Log .w (TAG , "No Notification Icon defined - push notifications will not be displayed" );
67
+ }
67
68
}
68
- }
69
69
70
- IterableNotification notificationBuilder = IterableNotification .createNotification (
71
- appContext , intent .getExtras (), mainClass , iconId );
70
+ IterableNotification notificationBuilder = IterableNotification .createNotification (
71
+ appContext , intent .getExtras (), mainClass , iconId );
72
72
73
- IterableNotification .postNotificationOnDevice (appContext , notificationBuilder );
73
+ IterableNotification .postNotificationOnDevice (appContext , notificationBuilder );
74
+ }
74
75
}
75
76
}
0 commit comments