-

   dunleadisc

 - e-mail

 

 -

 LiveInternet.ru:
: 10.12.2014
:
:
: 96

:


[ ] Firebase messaging

, 18 2016 . 18:40 +
"Push Android Firebase Cloud Messaging " , . Push- + . Main Activity . , layout activity_mail.xml TextView: . MainActivity : setContentView(R.layout.activity_main); Button subscribeButton = (Button) findViewById(R.id.subscribeButton); : TextView titleText = (TextView)findViewById(R.id.textView); TextView bodyText = (TextView)findViewById(R.id.textView2); // [START handle_data_extras] if (getIntent().getExtras() > MyFirebaseMessagingService onMessageReceived : public void onMessageReceived(RemoteMessage remoteMessage) { sendNotification (remoteMessage.getData().get("title"), remoteMessage.getData().get("body")); } sendNotification : private void sendNotification(String messageTitle, String messageBody) { Intent intent = new Intent(this, MainActivity.class); intent.putExtra("title", messageTitle); intent.putExtra("body", messageBody); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); Bitmap largeIcon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_krolik); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.mipmap.ic_stat_s1) .setLargeIcon(largeIcon) .setColor(Color.parseColor("#4B8A08")) .setStyle(new NotificationCompat.BigTextStyle().bigText(messageBody)) .setContentTitle(messageTitle) .setContentText(messageBody) .setAutoCancel(true) .setSound(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.circles0)) .setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 }) .setLights(Color.MAGENTA, 500, 1000) .setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); } R.drawable.ic_krolik , R.raw.circles0 .mp3 , raw. CURL. Raspberry Pi, : curl -s "https://gcm-http.googleapis.com/gcm/send" -H "Authorization: {"to": "fJuOOiTAk4w:APA91bHLrg95cyxodZDULzXU604BXJZUJKBaV8LHCbWPvMUlBhr6tzeD7TfNUp1rOMMObYmnC87OyqwRFbROjZV_pGUtNEh1fGFPDf0ApgljyDrLYEmAneKycVX5jCf8Rm2lpC7MDCss","priority" : "high", "vibrate": 1, "notification": { "title": "Port", "body" : "great", "sound": "circles0.mp3", "color": "#379F00", "icon" : "ic_stat_s"}, "data": {"title" : "3.21.15", "body": 12345678}}' , , . CURL PHP. CURL Raspberry Pi: sudo apt-get install curl libcurl3 libcurl3-dev php5-curl PHP: <?php // API access key from Google API's Console define( 'API_ACCESS_KEY', 'AIzaSyB4ZanJWaCay_fXxO5z0jI55T8UOwdGNNQ' ); $registrationIds = array( 'fJuOOiTAk4w:APA91bHLrg95cyxodZDULzXU604BXJZUJKBaV8LHCbWPvMUlBhr6tzeD7TfNUp1rOMMObYmnC87OyqwRFbROjZV_pGUtNEh1fGFPDf0ApgljyDrLYEmAneKycVX5jCf8Rm2lpC7MDCss' ); // prep the bundle $msg = array ( 'message' => 'here is a message. message', 'title' => 'This is a title. title', 'body' => 'This is a subtitle. subtitle, subtitle. subtitle subtitle. subtitle, subtitle. subtitle subtitle. subtitle, subtitle. subtitle subtitle. subtitle', 'tickerText' => 'Ticker text here...Ticker text here...Ticker text here', 'vibrate' => 1, 'sound' => 1, 'largeIcon' => 'large_icon', 'smallIcon' => 'small_icon' ); $fields = array ( 'registration_ids' => $registrationIds, 'data' => $msg ); $headers = array ( 'Authorization: Content-Type: application/json' ); $ch = curl_init(); curl_setopt( $ch,CURLOPT_URL, 'https://gcm-http.googleapis.com/gcm/send' ); curl_setopt( $ch,CURLOPT_POST, true ); curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers ); curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true ); curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false ); curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) ); $result = curl_exec($ch ); curl_close( $ch ); echo $result; ?> : php curl.php : , . ( ) activity TextView title body . , . , : activity Main2Activity. </application> : <activity > CURL "click_action": "OPEN_ACTIVITY_1"
????????? Winter Nights 2014

: [1] []
 

:
: 

: ( )

:

  URL