a/app/src/main/java/com/codesys/forge/MyService.java | b/app/src/main/java/com/codesys/forge/MyService.java | ||
---|---|---|---|
... |
... |
||
52 | NotificationManager notificationManager = getSystemService(NotificationManager.class); |
52 | NotificationManager notificationManager = getSystemService(NotificationManager.class); |
53 | notificationManager.createNotificationChannel(channel); |
53 | notificationManager.createNotificationChannel(channel); |
54 | } |
54 | } |
55 | } |
55 | } |
56 | private void CreateNotification(int id) { |
56 | private void CreateNotification(int id) { |
57 | String url; |
||
57 | String title; |
58 | String title; |
58 | String description; |
59 | String description; |
59 | 60 | ||
60 | switch(id) { |
61 | switch(id) { |
61 | case 1: |
62 | case 1: |
63 | url = "https://forge.codesys.com/forge/community-feed"; |
||
62 | title = getString(R.string.notification1_title); |
64 | title = getString(R.string.notification1_title); |
63 | description = getString(R.string.notification1_description); |
65 | description = getString(R.string.notification1_description); |
64 | break; |
66 | break; |
65 | case 2: |
67 | case 2: |
68 | url = "https://forge.codesys.com/forge/news"; |
||
66 | title = getString(R.string.notification2_title); |
69 | title = getString(R.string.notification2_title); |
67 | description = getString(R.string.notification2_description); |
70 | description = getString(R.string.notification2_description); |
68 | break; |
71 | break; |
69 | case 3: |
72 | case 3: |
73 | url = "https://forge.codesys.com/forge/talk"; |
||
70 | title = getString(R.string.notification3_title); |
74 | title = getString(R.string.notification3_title); |
71 | description = getString(R.string.notification3_description); |
75 | description = getString(R.string.notification3_description); |
72 | break; |
76 | break; |
73 | default: |
77 | default: |
78 | url = "url undefined"; |
||
74 | title = "title undefined"; |
79 | title = "title undefined"; |
75 | description = "description undefined"; |
80 | description = "description undefined"; |
76 | break; |
81 | break; |
77 | 82 | ||
78 | } |
83 | } |
79 | 84 | ||
80 | CreateNotificationChannel(); |
85 | CreateNotificationChannel(); |
81 | NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this); |
86 | NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this); |
82 | Intent intent = new Intent(this, MainActivity.class); |
87 | Intent intent = new Intent(this, MainActivity.class); |
83 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); |
88 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); |
89 | intent.putExtra("url", url); |
||
84 | PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0); |
90 | PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0); |
85 | 91 | ||
86 | NotificationCompat.Builder builder = new NotificationCompat.Builder(this, getString(R.string.channel_id)) |
92 | NotificationCompat.Builder builder = new NotificationCompat.Builder(this, getString(R.string.channel_id)) |
87 | .setSmallIcon(R.drawable.ic_codesys_logo) |
93 | .setSmallIcon(R.drawable.ic_codesys_logo) |
88 | .setContentTitle(title) |
94 | .setContentTitle(title) |