<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="de">
	<id>https://wiki.byte-welt.net/index.php?action=history&amp;feed=atom&amp;title=Push_Notifications_%28Android%29</id>
	<title>Push Notifications (Android) - Versionsgeschichte</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.byte-welt.net/index.php?action=history&amp;feed=atom&amp;title=Push_Notifications_%28Android%29"/>
	<link rel="alternate" type="text/html" href="https://wiki.byte-welt.net/index.php?title=Push_Notifications_(Android)&amp;action=history"/>
	<updated>2026-08-11T05:51:30Z</updated>
	<subtitle>Versionsgeschichte dieser Seite in Byte-Welt Wiki</subtitle>
	<generator>MediaWiki 1.46.0</generator>
	<entry>
		<id>https://wiki.byte-welt.net/index.php?title=Push_Notifications_(Android)&amp;diff=5043&amp;oldid=prev</id>
		<title>Eagleeye: Die Seite wurde neu angelegt: „ Push Notifications laufen bei Android über die Cloud Dienste von Google, C2DM. Für die Benutzung muss sich bei Google…“</title>
		<link rel="alternate" type="text/html" href="https://wiki.byte-welt.net/index.php?title=Push_Notifications_(Android)&amp;diff=5043&amp;oldid=prev"/>
		<updated>2012-02-23T09:49:29Z</updated>

		<summary type="html">&lt;p&gt;Die Seite wurde neu angelegt: „&lt;a href=&quot;/index.php?title=Push_Notification&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Push Notification (Seite nicht vorhanden)&quot;&gt; Push Notifications&lt;/a&gt; laufen bei &lt;a href=&quot;/index.php?title=Android&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Android (Seite nicht vorhanden)&quot;&gt;Android&lt;/a&gt; über die &lt;a href=&quot;/index.php?title=Cloud&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Cloud (Seite nicht vorhanden)&quot;&gt;Cloud&lt;/a&gt; Dienste von &lt;a href=&quot;/index.php?title=Google&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Google (Seite nicht vorhanden)&quot;&gt;Google&lt;/a&gt;, &lt;a href=&quot;/index.php?title=C2DM&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;C2DM (Seite nicht vorhanden)&quot;&gt;C2DM&lt;/a&gt;. Für die Benutzung muss sich bei Google…“&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Neue Seite&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Push Notification | Push Notifications]] laufen bei [[Android]] über die [[Cloud]] Dienste von [[Google]], [[C2DM]].&lt;br /&gt;
Für die Benutzung muss sich bei Google registriert werden, sowie bei C2DM (http://code.google.com/intl/de-DE/android/c2dm/signup.html)&lt;br /&gt;
&lt;br /&gt;
==Ablauf==&lt;br /&gt;
In der Kommunikation für die PNs existieren 3 Parteien das Gerät, die Google Cloud (C2DM) und der eigene Server für die PNs.&lt;br /&gt;
&lt;br /&gt;
[[Bild:PN-Kommunikation.png]]&lt;br /&gt;
===Client meldet sich am C2DM an===&lt;br /&gt;
Im 1. Schritt fragt der Client ein Token beim C2DM an, hier ist zu beachten das jede Anfrage ein neues Token generiert.&lt;br /&gt;
&amp;lt;code=java&amp;gt;&lt;br /&gt;
        Intent registrationIntent = new Intent(GOOGLE_C2DM_REGISTER);&lt;br /&gt;
        registrationIntent.putExtra(&amp;quot;app&amp;quot;, PendingIntent.getBroadcast(context, 0, new Intent(), 0));&lt;br /&gt;
        registrationIntent.putExtra(&amp;quot;sender&amp;quot;, senderEMail);&lt;br /&gt;
        context.startService(registrationIntent);&lt;br /&gt;
&amp;lt;/code=java&amp;gt;&lt;br /&gt;
Für das Empfangen des Responses muss ein [[Android Receiver|Receiver]] registriert werden&lt;br /&gt;
&amp;lt;code=xml&amp;gt;        &amp;lt;receiver&lt;br /&gt;
            android:name=&amp;quot;.aos.pushnotification.C2DMListener&amp;quot;&lt;br /&gt;
            android:permission=&amp;quot;com.google.android.c2dm.permission.SEND&amp;quot; &amp;gt;&lt;br /&gt;
&lt;br /&gt;
            &amp;lt;!-- Receive the actual message --&amp;gt;&lt;br /&gt;
            &amp;lt;intent-filter &amp;gt;&lt;br /&gt;
                &amp;lt;action android:name=&amp;quot;com.google.android.c2dm.intent.RECEIVE&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
                &amp;lt;category android:name=&amp;quot;&amp;lt;packagename&amp;gt;&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;/intent-filter&amp;gt;&lt;br /&gt;
            &amp;lt;!-- Receive the registration id --&amp;gt;&lt;br /&gt;
            &amp;lt;intent-filter &amp;gt;&lt;br /&gt;
                &amp;lt;action android:name=&amp;quot;com.google.android.c2dm.intent.REGISTRATION&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
                &amp;lt;category android:name=&amp;quot;&amp;lt;packagename&amp;gt;&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;/intent-filter&amp;gt;&lt;br /&gt;
        &amp;lt;/receiver&amp;gt;&lt;br /&gt;
&amp;lt;/code=xml&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code=java&amp;gt;&lt;br /&gt;
public class C2DMListener extends BroadcastReceiver&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
    @Override&lt;br /&gt;
    public void onReceive(Context context, Intent intent)&lt;br /&gt;
    {&lt;br /&gt;
        System.out.println(&amp;quot;C2DMListener.onReceive()&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        try&lt;br /&gt;
        {&lt;br /&gt;
            if (intent.getAction().equals(&amp;quot;com.google.android.c2dm.intent.REGISTRATION&amp;quot;))&lt;br /&gt;
            {&lt;br /&gt;
                String registration = intent.getStringExtra(&amp;quot;registration_id&amp;quot;);&lt;br /&gt;
                if (intent.getStringExtra(&amp;quot;error&amp;quot;) != null)&lt;br /&gt;
                {&lt;br /&gt;
                    System.out.println(&amp;quot;Error: &amp;quot; + intent.getStringExtra(&amp;quot;error&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
                }&lt;br /&gt;
                else if (intent.getStringExtra(&amp;quot;unregistered&amp;quot;) != null)&lt;br /&gt;
                {&lt;br /&gt;
                    System.out.println(&amp;quot;Unregistred: &amp;quot; + intent.getStringExtra(&amp;quot;unregistered&amp;quot;));&lt;br /&gt;
                }&lt;br /&gt;
                else if (registration != null)&lt;br /&gt;
                {&lt;br /&gt;
                    System.out.println(&amp;quot;RegId: &amp;quot; + registration);&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
            else if (intent.getAction().equals(&amp;quot;com.google.android.c2dm.intent.RECEIVE&amp;quot;))&lt;br /&gt;
            {&lt;br /&gt;
                //push notification received&lt;br /&gt;
            }&lt;br /&gt;
            else&lt;br /&gt;
                System.out.println(&amp;quot;Unknown action: &amp;quot; + intent);&lt;br /&gt;
&lt;br /&gt;
            setResult(Activity.RESULT_OK, null /* data */, null /* extra */);&lt;br /&gt;
        }&lt;br /&gt;
        catch (Exception e)&lt;br /&gt;
        {&lt;br /&gt;
            e.printStackTrace();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code=java&amp;gt;&lt;br /&gt;
===Registrierung am Server===&lt;br /&gt;
Ist das Token erhalten kann man es an den eigenen Server schicken.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Senden von Daten===&lt;br /&gt;
Hat sich der Client beim Server mit dem Token registriert, kann dieser über diese Adresse Notifications an den Client schicken. &lt;br /&gt;
Der Header muss dazu das Feld &amp;quot;Authorization&amp;quot; mit dem Google Key enthalten, im Body des POST Requests werden die weiteren Informationen geschickt:&lt;br /&gt;
* &amp;#039;&amp;#039;collapse_key&amp;#039;&amp;#039; - Key mit dem Nachrichten zusammen gefasst werden&lt;br /&gt;
* &amp;#039;&amp;#039;data.&amp;lt;key&amp;gt;&amp;#039;&amp;#039; - Datenfeld das vom Anwender bestimmt werden, diese Datenfelder werden an die AOS App weitergereicht und können von dieser Ausgewertet werden&lt;br /&gt;
* &amp;#039;&amp;#039;registration_id&amp;#039;&amp;#039; - Token des Gerätes&lt;br /&gt;
&lt;br /&gt;
Diese Daten werden als POST Request an die C2DM Server geschickt (&amp;#039;&amp;#039;&amp;#039;https://android.apis.google.com/c2dm/send&amp;#039;&amp;#039;&amp;#039;).&lt;br /&gt;
Den Key für die Authentifizierung muss gesondert angefragt werden, hierzu muss ein Google Account existieren und die App bei Google registriert sein&lt;br /&gt;
(Wobei ich glaub das ist verarsche, Hauptsache der Account hat einmal einen Request für irgend ein Package an Google geschickt, die Keys gehen bisher für alle Apps, egal welchen Packagenamen sie haben)&lt;br /&gt;
Dies erfolgt über die Webseite http://code.google.com/intl/de-DE/android/c2dm/signup.html&lt;br /&gt;
Nach einigen Tagen erhält man eine [[EMail]] und man kann über den Request anfordern. Dazu muss ein POST Request mit dem Boddy&lt;br /&gt;
 accountType=HOSTED_OR_GOOGLE&amp;amp;Email=&amp;lt;google ID&amp;gt;&amp;amp;Passwd=&amp;lt;password&amp;gt;&amp;amp;service=ac2dm&amp;amp;source=blabliblub&lt;br /&gt;
An https://www.google.com/accounts/ClientLogin geschickt werden.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Kategorie:Android]]&lt;br /&gt;
[[Kategorie:Google]]&lt;/div&gt;</summary>
		<author><name>Eagleeye</name></author>
	</entry>
</feed>