GithubHelp home page GithubHelp logo

unity-gcm's Introduction

THIS PROJECT IS NOT MAINTAINTED NOW.

unity-gcm

About this repository

This is an Unity plugin to use Google Cloud Messaging (GCM) for Android. By using this plugin, you can implement GCM without writing Java code.

  • Receive GCM events in C#/UnityScript/Boo layer
  • Show notification view in Android status bar

Installation

Download .unitypackage file from here

And import the file into your Unity project.

Developer Guide

For contributors

Known Issues

Licenses

Copyright 2013 Keisuke Kobayashi

This software is licensed under Apache License 2.0

unity-gcm's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unity-gcm's Issues

Show notification

Hi
To Show notification view in Android status bar

By sending GCM with the defined fields, this plugin can show notification view in Android status bar (the notification will only be shown if all 3 fields are set).
ticker
content_text
content_title
-= > How to do this ?
which file i need to use to display notification .
Please help.

Native method not found: com.unity3d.player.UnityPlayer.UnitySendMessage

First thanks for this asset!

When i receive a message when the application is closed im getting this error on logcat.

E/AndroidRuntime(3480): Caused by: java.lang.UnsatisfiedLinkError: Native method not found: com.unity3d.player.UnityPlayer.UnitySendMessage:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)
08-08 16:20:45.005: E/AndroidRuntime(3480): at com.kskkbys.unitygcmplugin.Util.sendMessage(Util.java:22)
08-08 16:20:45.005: E/AndroidRuntime(3480): at com.kskkbys.unitygcmplugin.Util.sendMessage(Util.java:22)
08-08 16:20:45.005: E/AndroidRuntime(3480): at com.kskkbys.unitygcmplugin.UnityGCMIntentService.onMessage(UnityGCMIntentService.java:50)

Resume app instead of restart when tapping the notification

Hey,

thanks for the code, works great for me. But I have one problem: When I receive the notification and the app is in background and I then tap the notification in the status bar, it will restart my app (so that I am on the start screen of my app). But I want it to resume the app in the last state as I left it.

Any ideas about that?

Regards,
henrik

crashes on run time...

java.lang.IllegalStateException: sender id not set on constructor
at com.google.android.gcm.GCMBaseIntentService.getSenderIds(GCMBaseIntentService.java:125)
at com.google.android.gcm.GCMBaseIntentService.onHandleIntent(GCMBaseIntentService.java:237)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:154)
at android.os.HandlerThread.run(HandlerThread.java:65)
error shows on run time..

Package not updated

I saw some changes to the ticker text and notification message to be optional but this is not applied in the package itself but it is in the source code. Please update?

crash when no internet (and not yet registered?)

We got crash in our app.
Crash occurs after we install app , trying to run it, and wi-fi is off.
If we turn wi-fi on, then there is on crash. And after that, if we turn wi-fi off and launches our app, there is no crash.
So we think it can be related to Register

06-18 10:32:26.555: W/SocketClient(1691): write error (Broken pipe)
06-18 10:32:27.486: V/WindowOrientationListener(2052): nearestRotation : 0 Angle: 358 tilt: 59
06-18 10:32:27.636: V/GCMBroadcastReceiver(15883): onReceive: com.google.android.gcm.intent.RETRY
06-18 10:32:27.636: V/UnityGCMBroadcastReceiver(15883): getGCMIntentServcieClassName
06-18 10:32:27.636: V/GCMBroadcastReceiver(15883): GCM IntentService class: com.kskkbys.unitygcmplugin.UnityGCMIntentService
06-18 10:32:27.636: V/GCMBaseIntentService(15883): Acquiring wakelock
06-18 10:32:27.636: V/AlarmManager(2052): waitForAlarm result :8
06-18 10:32:27.666: V/GCMBaseIntentService(15883): Intent service name: GCMIntentService-DynamicSenderIds-2
06-18 10:32:27.666: V/GCMBaseIntentService(15883): Releasing wakelock
06-18 10:32:27.666: W/dalvikvm(15883): threadid=25: thread exiting with uncaught exception (group=0x40d552a0)
06-18 10:32:27.666: E/AndroidRuntime(15883): FATAL EXCEPTION: IntentService[GCMIntentService-DynamicSenderIds-2]
06-18 10:32:27.666: E/AndroidRuntime(15883): java.lang.Error: FATAL EXCEPTION [IntentService[GCMIntentService-DynamicSenderIds-2]]
06-18 10:32:27.666: E/AndroidRuntime(15883): Unity version : 4.6.5p4
06-18 10:32:27.666: E/AndroidRuntime(15883): Device model : samsung GT-I8190
06-18 10:32:27.666: E/AndroidRuntime(15883): Device fingerprint: samsung/goldenxx/golden:4.1.2/JZO54K/I8190XXAMG1:user/release-keys
06-18 10:32:27.666: E/AndroidRuntime(15883): Caused by: java.lang.IllegalStateException: sender id not set on constructor
06-18 10:32:27.666: E/AndroidRuntime(15883): at com.google.android.gcm.GCMBaseIntentService.getSenderIds(GCMBaseIntentService.java:125)
06-18 10:32:27.666: E/AndroidRuntime(15883): at com.google.android.gcm.GCMBaseIntentService.onHandleIntent(GCMBaseIntentService.java:237)
06-18 10:32:27.666: E/AndroidRuntime(15883): at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
06-18 10:32:27.666: E/AndroidRuntime(15883): at android.os.Handler.dispatchMessage(Handler.java:99)
06-18 10:32:27.666: E/AndroidRuntime(15883): at android.os.Looper.loop(Looper.java:137)
06-18 10:32:27.666: E/AndroidRuntime(15883): at android.os.HandlerThread.run(HandlerThread.java:60)
06-18 10:32:27.716: E/android.os.Debug(2052): !@dumpstate > dumpstate -k -t -z -d -o /data/log/dumpstate_app_error
06-18 10:32:27.736: I/dumpstate(15987): begin
06-18 10:32:31.039: D/BatteryService(2052): update start
06-18 10:32:31.049: D/BatteryService(2052): level:98 scale:100 status:2 health:2 present:true voltage: 4301 temperature: 345 technology: Li-ion AC powered:false USB powered:true icon:17303270 invalid charger:0 online:4 charge type:0 current avg:62
06-18 10:32:31.710: W/Unity(15883): Timeout while trying to pause the Unity Engine.

Receive message when app openning

Hi, when I send a message (not notification) to a device how my app is close, The app not receive the message when I open it again. But I receive messages if I send when the app is open.
Is it possible to do that if yes how can I do?
Thanks
PS : my app are register on server and the lifespan is :2419200

here c# code for send message

public string SendMessage(string deviceId, string message)
{
string GoogleAppID = "XXXX";
var SENDER_ID = "XXXX";
var value = message;
WebRequest tRequest;
tRequest = WebRequest.Create("https://android.googleapis.com/gcm/send");
tRequest.Method = "post";
tRequest.ContentType = " application/x-www-form-urlencoded;charset=UTF-8";
tRequest.Headers.Add(string.Format("Authorization: key={0}", GoogleAppID));

        tRequest.Headers.Add(string.Format("Sender: id={0}", SENDER_ID));

        string postData = "collapse_key="+collapseTb.Text+"&time_to_live=2419200&delay_while_idle=true&data.message=" + value + "&data.time=" + System.DateTime.Now.ToString() + "&registration_id=" + deviceId + "";

        Console.WriteLine(postData);
        Byte[] byteArray = Encoding.UTF8.GetBytes(postData);
        tRequest.ContentLength = byteArray.Length;

        Stream dataStream = tRequest.GetRequestStream();
        dataStream.Write(byteArray, 0, byteArray.Length);
        dataStream.Close();

        WebResponse tResponse = tRequest.GetResponse();

        dataStream = tResponse.GetResponseStream();

        StreamReader tReader = new StreamReader(dataStream);

        String sResponseFromServer = tReader.ReadToEnd();

        tReader.Close();
        dataStream.Close();
        tResponse.Close();
        return sResponseFromServer;
    }

Updated unitypackage

Unitypackage not contains last fix. e.x. setNotificationsEnabled. Please update.

Change notification icon

Hi,first of all thank you for sharing this plugin with the community.

I would like to ask how to change the notification icon. I know that the icon used by default is the App icon, but what if I want to use one specific for notifications? Is it possible to do so? I've been digging in the code to try to find a way to do this but I haven't been lucky.

Thanks

notification does not start the application

http://stackoverflow.com/questions/28052802/gcm-notification-received-on-device-does-not-start-the-application

This is the error I get in logcat:

Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:1505 com.android.server.StatusBarManagerService.sendNotification:985 com.android.server.StatusBarManagerService.removeNotification:710 com.android.server.NotificationManagerService.cancelNotificationLocked:2469 com.android.server.NotificationManagerService.access$5100:162

Use the latest Google Play Services

The current implementation uses the old version of GCM library, which is deprecated by Google.
Must use Google Play Services instead of the deprecated library.

gcm

Hello!
Before, I never worked with ruby.
I try to execute ruby script, but I get error:

c:\RubyFiles>ruby notif.rb
c:/Ruby22/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in require': ca nnot load such file -- gcm (LoadError) from c:/Ruby22/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in require'
from notif.rb:1:in `

'

Where can I get file gcm?

Can not Receive message when app openning or closing

Hi, when I send a message (from server) to a device how my app is close or open, The app not receive the message In the form of pop up or notification in the top bar device. but the message show in the text in the
app!!!
why???
in the android plugin the method "showNotification(...)" build a notification bar with icon and message but
the unity not show notification bar In the form of pop up or notification in the top bar device .
please help me.

photo_2018-08-08_10-57-19

touch on notification not opening the app

When touch on notification on status bar it doesn't open the app. I get the following log.. It doesn't show any error/problem either.

W/ContextImpl( 803): Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:1523 com.android.server.StatusBarManagerService.sendNotification:981 com.android.server.StatusBarManagerService.removeNotification:706 com.android.server.NotificationManagerService.cancelNotificationLocked:2455 com.android.server.NotificationManagerService.access$5100:160
D/LightsService( 803): [SvcLED] setSvcLedLightLocked :: Current SvcLED(id=4) maintains its priority right
D/STATUSBAR-IconMerger( 1025): checkOverflow(1152), More:false, Req:false Child:3
D/NotificationService( 803): cancelNotificationLocked
D/NotificationService( 803): hasClearableItems
D/NotificationService( 803): has clearable items no
D/NotificationService( 803): cancelNotificationLocked: cancel alarm
D/NotificationService( 803): cancelNotificationLocked: cancel alarm
D/STATUSBAR-StatusBarManagerService( 803): sendNotification(3) - 1
D/LightsService( 803): [api] [SvcLED] turnOff:: id = 4 (uid: 1000 pid: 803)
D/LightsService( 803): [SvcLED] setSvcLedStateLocked:: SvcLEDState : 0x0 -> 0x0 | SvcLED(id=4) set Off
D/LightsService( 803): [SvcLED] Lux failed to be updated in 700ms. -> handleForcedSvcLEDTasK
D/LightsService( 803): [SvcLED] setSvcLedLightLocked :: Current SvcLED(id=4) maintains its priority right
E/SmartFaceService - 3rd party pause( 803): onReceive, ACTION_STATUS_BAR_COLLAPSED: false
D/SSRMv2:TSP:AirViewOnOff( 803): DeviceInfo:: 00001010000
D/SSRMv2:TSP:AirViewOnOff( 803): SettingsAirViewInfo:: 000000000
I/Process ( 6678): Sending signal. PID: 6678 SIG: 9
I/ActivityManager( 803): Process com.sec.yosemite.tab (pid 6678) (adj 0) has died.
D/STATUSBAR-PhoneStatusBar( 1025): makeExpandedInvisible
D/STATUSBAR-PhoneStatusBar( 1025): Mini Controller text scroll : OFF
D/STATUSBAR-QuickSettingPanel( 1025): setSingleLine:true
D/STATUSBAR-QuickSettingPanel( 1025): updateButtonInfo mButtonWidth : 228 mColumnNumber:7 orien: 1
I/SpenGestureManager( 803): setFocusWindow21045
D/STATUSBAR-StatusBarManagerService( 803): manageDisableList what=0x0 pkg=WindowManager.LayoutParams
D/PointerIcon( 803): setMouseIconStyle1 pointerType: 1001iconType:101 flag:0
D/PointerIcon( 803): setMouseCustomIcon IconType is same.101
D/PointerIcon( 803): setHoveringSpenIconStyle1 pointerType: 10001iconType:1 flag:0
D/PointerIcon( 803): setHoveringSpenCustomIcon IconType is same.1
D/AbsListView( 1219): unregisterIRListener() is called
D/AbsListView( 1219): unregisterIRListener() is called
D/AbsListView( 1219): unregisterIRListener() is called
D/AbsListView( 1219): unregisterIRListener() is called
D/AbsListView( 1219): unregisterIRListener() is called
D/AbsListView( 1219): unregisterIRListener() is called
D/AbsListView( 1219): unregisterIRListener() is called
D/AbsListView( 1219): unregisterIRListener() is called
D/AbsListView( 1219): unregisterIRListener() is called
D/AbsListView( 1219): unregisterIRListener() is called
D/AbsListView( 1219): unregisterIRListener() is called

hey! about push not in the app...

i got this erorr:

D/dalvikvm( 9994): threadid=10
(IntentService[GCMIntentService-DynamicSenderIds-1]): calling run()
V/UnityGCMIntentService( 9994): onMessage
V/UnityGCMIntentService( 9994): badge: 7
V/UnityGCMIntentService( 9994): collapse_key: do_not_collapse
V/UnityGCMIntentService( 9994): from: 149262229651
V/UnityGCMIntentService( 9994): alert: gvgvgv
D/dalvikvm( 9994): Trying to load lib
/data/app-lib/com.slotoparty.slotoparty-1/libmain.so 0x41ba9978
D/dalvikvm( 9994): Added shared lib
/data/app-lib/com.slotoparty.slotoparty-1/libmain.so 0x41ba9978
W/dalvikvm( 9994): No implementation found for native
Lcom/unity3d/player/UnityPlayer;.UnitySendMessage:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
W/System.err( 9994): java.lang.UnsatisfiedLinkError: Native method not
found: com.unity3d.player.UnityPlayer.UnitySendMessage:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
W/System.err( 9994): at
com.unity3d.player.UnityPlayer.UnitySendMessage(Native Method)
W/System.err( 9994): at
com.kskkbys.unitygcmplugin.Util.sendMessage(Util.java:23)
W/System.err( 9994): at
com.kskkbys.unitygcmplugin.UnityGCMIntentService.onMessage(UnityGCMIntentService.java:50)
W/System.err( 9994): at
com.google.android.gcm.GCMBaseIntentService.onHandleIntent(GCMBaseIntentService.java:223)
W/System.err( 9994): at
android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
W/System.err( 9994): at android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err( 9994): at android.os.Looper.loop(Looper.java:153)
W/System.err( 9994): at android.os.HandlerThread.run(HandlerThread.java:60)

id run over all threads here try everything still not working what can i do?

thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.