GCM推送通知在Android Phonegap应用程序中无效[关闭](GCM push notification not working in Android Phonegap application [closed])
我在HTML5 Phonegap android
GCM push notification
应用程序中工作。 但我尝试了几次但没有得到任何结果:-(请帮助我..我试过这个过去三天的工作。
我使用Push插件:
com.phonegap.plugins.PushPlugin
**我的Js代码:
document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() { alert('deviceready'); // result contains any message sent from the plugin call var app = { successHandler: function(result) { alert('Callback Success! Result = '+result) }, errorHandler:function(error) { alert(error); }, onNotificationGCM: function(e) { alert('onNotificationGCM'); switch( e.event ) { case 'registered': if ( e.regid.length > 0 ) { console.log("Regid " + e.regid); alert('registration id = '+e.regid); } break; case 'message': // this is the actual push notification. its format depends on the data model from the push server alert('message = '+e.message+' msgcnt = '+e.msgcnt); break; case 'error': alert('GCM error = '+e.msg); break; default: alert('An unknown GCM event has occurred'); break; } } } setTimeout(function(){ var pushNotification = window.plugins.pushNotification; pushNotification.register(app.successHandler, app.errorHandler,{"senderID":"236728063055","ecb":"app.onNotificationGCM"}); },2000); }
**清单文件
<?xml version='1.0' encoding='utf-8'?> <manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="com.test.pushDummy" xmlns:android="http://schemas.android.com/apk/res/android"> <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" /> <uses-permission android:name="android.permission.INTERNET" /> <application android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="CordovaApp" android:theme="@android:style/Theme.Black.NoTitleBar" android:windowSoftInputMode="adjustResize"> <intent-filter android:label="@string/launcher_name"> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:exported="true" android:name="com.plugin.gcm.PushHandlerActivity" /> <receiver android:name="com.plugin.gcm.CordovaGCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND"> <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <category android:name="com.test.pushDummy" /> </intent-filter> </receiver> <service android:name="com.plugin.gcm.GCMIntentService" /> </application> <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <permission android:name="com.test.pushDummy.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="com.test.pushDummy.permission.C2D_MESSAGE" /> </manifest>
Am working in HTML5 Phonegap android
GCM push notification
application. But I tried several times but not getting any results :-(Please help me.. Am trying this to work from last three days.
Am using Push plugin :
com.phonegap.plugins.PushPlugin
** My Js code:
document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() { alert('deviceready'); // result contains any message sent from the plugin call var app = { successHandler: function(result) { alert('Callback Success! Result = '+result) }, errorHandler:function(error) { alert(error); }, onNotificationGCM: function(e) { alert('onNotificationGCM'); switch( e.event ) { case 'registered': if ( e.regid.length > 0 ) { console.log("Regid " + e.regid); alert('registration id = '+e.regid); } break; case 'message': // this is the actual push notification. its format depends on the data model from the push server alert('message = '+e.message+' msgcnt = '+e.msgcnt); break; case 'error': alert('GCM error = '+e.msg); break; default: alert('An unknown GCM event has occurred'); break; } } } setTimeout(function(){ var pushNotification = window.plugins.pushNotification; pushNotification.register(app.successHandler, app.errorHandler,{"senderID":"236728063055","ecb":"app.onNotificationGCM"}); },2000); }
** Manifest file
<?xml version='1.0' encoding='utf-8'?> <manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="com.test.pushDummy" xmlns:android="http://schemas.android.com/apk/res/android"> <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" /> <uses-permission android:name="android.permission.INTERNET" /> <application android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="CordovaApp" android:theme="@android:style/Theme.Black.NoTitleBar" android:windowSoftInputMode="adjustResize"> <intent-filter android:label="@string/launcher_name"> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:exported="true" android:name="com.plugin.gcm.PushHandlerActivity" /> <receiver android:name="com.plugin.gcm.CordovaGCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND"> <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <category android:name="com.test.pushDummy" /> </intent-filter> </receiver> <service android:name="com.plugin.gcm.GCMIntentService" /> </application> <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <permission android:name="com.test.pushDummy.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="com.test.pushDummy.permission.C2D_MESSAGE" /> </manifest>
原文:https://stackoverflow.com/questions/29692162
最满意答案
选项1:使用x264制作自己的作品。 这些不是标准的示例文件,但您可以控制它们使用的H.264的哪些部分,例如不同的配置文件/级别/等等,使它们仅限I帧,使它们仅具有特定的宏块类型等。另外,您可以使它们很小,例如一帧或几帧。
选项2:也许JM软件附带一些样本文件? http://iphome.hhi.de/suehring/tml/
选项3:如果你想测试大量的文件,请下载一些随机预告片等在mp4 formar和demux他们得到原始.h264(例如与ffmpeg -vcodec副本)
Option 1: make your own with x264. These are not standard sample files, but you can control which parts of H.264 they use, for example different profile/level/etc, make them I-frame-only, make them have only a particular macroblock type, etc. Also you can make them tiny, e.g. one or a few frames long.
Option 2: perhaps the JM software comes with some sample files? http://iphome.hhi.de/suehring/tml/
Option 3: if you want to test a large number of files, download some random trailers etc in mp4 formar and demux them to get raw .h264 (for example with ffmpeg -vcodec copy)
相关问答
更多-
h264无损编码(h264 lossless coding)[2023-08-12]
我花了整整一天的时间试图弄清楚如何将YUV 4:4:4像素转换为x264,然后再添加一个较迟的答案。 虽然x264确实接受文件中的原始4:2:0像素,但传入4:4:4像素确实非常困难。对于最新版本的ffmpeg,以下工作可用于完全无损编码和提取以验证编码。 首先,将原始yuv 4:4:4像素以平面格式写入文件。 平面是一组Y字节,然后是U和V字节,其中U和V使用128作为零值。 现在,调用ffmpeg并像原样使用“yuv444p”像素格式一样传递原始YUV帧的大小,如下所示: ffmpeg -y -s 48 ... -
Gstreamer流h264文件(Gstreamer stream h264 File)[2022-05-15]
刚刚从gstreamer邮件列表中得到了答案。 在其他人遇到同样问题的情况下,添加gstrtpjitterbuffer元素可以修复它。 gst-launch-0.10 udpsrc port=5000 \ caps="application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, sprop-parameter-sets=(string)\"J01AHqkYGwe83gDUBAQG2wrXv ... -
好的,我实际上设法解决了这个问题: 就像我之前说过的那样-fps 120选项可以让玩家在收到buffor和播放流时立即跳过它。 PanelId是mplayer嵌套的面板的句柄。 class Mplayer { Process mplayer; public Mplayer(string path, string pipeName, int panelId) { String args = ""; mplayer = new Process(); ...
-
好吧,只是解析比特流来找到每个I帧有点棘手; 除其他事项外,编码顺序可能(或不)与显示顺序不同。 一个解决方案是使用ffmpeg套件中的http://www.ffmpeg.org/ffprobe.html 。 例: ffprobe -show_frames input.bin | grep key_frame key_frame=1 key_frame=0 key_frame=0 key_frame=0 key_frame=0 key_frame=0 ... 从输出中您可以轻松计算GOP长度 另一种解决方 ...
-
如果你得到原始的h264(avc格式),它可能无法作为文件播放。 您可以强制将其转换为字节流,可以直接保存到文件或使用带有avc的容器。 gst-launch-1.0 -e -v udpsrc port=5000 ! application/x-rtp, clock-rate=90000, encoding-name=H264, payload=96 ! rtpjitterbuffer ! rtph264depay ! h264parse ! "video/x-h264, format=byte-strea ...
-
最后我自己解决了。 事实证明,您只需要匹配图像大小和宽高比,因此它可以像下面这样简单: x264_param_t xparam ; x264_param_default( &xparam ); xparam.i_width = width ; xparam.i_height = height ; xparam.vui.i_sar_height = 1 ; xparam.vui.i_sar_width = 1 ; x264_t * x264 = x ...
-
.h264示例文件(.h264 sample file)[2023-12-23]
选项1:使用x264制作自己的作品。 这些不是标准的示例文件,但您可以控制它们使用的H.264的哪些部分,例如不同的配置文件/级别/等等,使它们仅限I帧,使它们仅具有特定的宏块类型等。另外,您可以使它们很小,例如一帧或几帧。 选项2:也许JM软件附带一些样本文件? http://iphome.hhi.de/suehring/tml/ 选项3:如果你想测试大量的文件,请下载一些随机预告片等在mp4 formar和demux他们得到原始.h264(例如与ffmpeg -vcodec副本) Option 1: m ... -
我最终使用FFmpeg并且没有使用GPL许可证。 这是我如何设置它: 我从source forge下载了FFmpeg iOS库。 (您也可以通过下载构建脚本从头开始构建它: https : //github.com/kewlbear/FFmpeg-iOS-build-script ) 在代码中,我添加了一个检查,以查看我所使用的操作系统版本: uint8_t *data = (unsigned char*)buf; float version = [[[UIDevice currentDevice] sys ...
-
Quicktime不支持原始基本流。 您必须将es放入容器(如mp4)中。 ffmpeg -i test.h.264 -codec copy test.mp4 Quicktime does not support raw elementary streams. You must put the es in a container such as mp4. ffmpeg -i test.h.264 -codec copy test.mp4
-
H264流的错误演示时间[Live555 OpenRtspClient](Wrong Presentation time at H264 streams [Live555 OpenRtspClient])[2022-05-24]
部分回答你的问题: 在图书馆计算“presentationTime”的地方? 是否有可能H264VideoFileSink :: afterGettingFrame1方法的“presentationTime”值可能出错? 演示时间基于样本的RTP时间戳。 不太可能,我们已经使用live555很长一段时间没有任何时间戳问题。 如果时间戳不正确,我会怀疑RTP源(即RTSP服务器或摄像头)的时间戳是错误的。 使用wireshark嗅探RTP数据包以查看RTP时间戳然后从那里转换回NTP时间以查看连续帧之间的差异 ...