我刚刚在iOS中成功实现了示例推送通知.目前,我在发送消息时使用了设备令牌.现在,我有一个关于推送通知要求的问题.我们可以使用UDID推送通知设备代替设备令牌吗?我知道设备令牌可以单独完成工作但是可以UDID用于推送通知吗?Apple允许吗?
我通过推送通知实现了我的iPhone应用程序.我基本上成功实现了推送通知.当我点击推送通知消息时,该消息将显示在ViewController上的消息标签上.但是,当我打开图标(应用程序)时,它没有返回任何通知.我需要显示推送通知,不仅要点击推送通知,而且如果iOS用户也只是打开应用程序,它应该有效.
这是我的代码.
AppDelegate.m
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary
*)launchOptions
{
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
}
- (void)application:(UIApplication*)application didReceiveRemoteNotification: (NSDictionary*)userInfo{
NSString *messageAlert = [[userInfo objectForKey:@"aps"] objectForKey:@"alert"];
NSLog(@"Received Push Message: %@", messageAlert );
[[NSNotificationCenter defaultCenter] postNotificationName:@"MyNotification" object:messageAlert];
Run Code Online (Sandbox Code Playgroud)
在我的ViewController.m上
- (void)viewDidLoad
{
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserverForName:@"MyNotification" object:nil queue:nil usingBlock:^(NSNotification *note) {
NSString *_string = note.object;
messages.text = _string; //message
}];
}
}
Run Code Online (Sandbox Code Playgroud)
它会在我点击通知时显示通知.但是当我打开应用程序时,通知也必须显示该消息.怎么做?请帮我.
我需要在选择器视图中设置文本的对齐方式,但我的解决方案不起作用.到目前为止这是我的代码.我使用数组在选择器视图上存储值.
- (void)viewDidLoad{
[super viewDidLoad];
self.source = [[NSMutableArray alloc]
initWithObjects:@" 5 Minutes", @"10 Minutes", @"15 Minutes", @"20 Minutes",@"25 Minutes",@"30 Minutes",@"35 Minutes",@"40 Minutes",@"45 Minutes",@"50 Minutes",@"55 Minutes",@"60 Minutes", nil];
self.picker = [[UIPickerView alloc] initWithFrame:CGRectMake(0.0, 275.0, 320.0, 120.0)];
self.picker.delegate = self;
self.picker.dataSource = self;
[self.view addSubview:self.picker];
[self.picker selectRow:2 inComponent:0 animated:YES];}
Run Code Online (Sandbox Code Playgroud)
然后,
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
return [source objectAtIndex:row];
}
- (NSInteger)numberOfComponentsInPickerView:
(UIPickerView *)pickerView
{
return 1;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView
numberOfRowsInComponent:(NSInteger)component
{
return [source count];
}
Run Code Online (Sandbox Code Playgroud)
但是,它在显示值时工作正常.但是当我在中心对齐文本时,选择器视图变为空,而不是显示文本(选择器视图上的值).这是关于我如何在中心完成对齐的代码.
- (UIView *)pickerView:(UIPickerView …Run Code Online (Sandbox Code Playgroud) 我现在遇到麻烦,关于如何使我的存储过程SqlDataSource在aspx页面上工作.
这是我的标记:
<asp:SqlDataSource ID="SqlDataSourceGrantInfo" runat="server"
ConnectionString="<%# _connection.strConnectionString %>"
SelectCommand='<%# "EXEC dbo._GetCurrentSession " + Eval("Film_strCode") + " " %>' />
Run Code Online (Sandbox Code Playgroud)
上面的代码工作正常,但没有单引号.但是,当我试图单引号时,它不起作用.标签上会出错.
看到这个标记:
<asp:SqlDataSource ID="SqlDataSourceGrantInfo" runat="server"
ConnectionString="<%# _connection.strConnectionString %>"
SelectCommand='<%# "EXEC dbo._GetCurrentSession 'some_value_here' " %>' />
Run Code Online (Sandbox Code Playgroud)
请帮助我知道为什么单引号的存储过程在aspx页面上不起作用?我需要用单引号制作我的代码,但它不起作用.
<asp:SqlDataSource ID="SqlDataSourceGrantInfo" runat="server"
ConnectionString="<%# _connection.strConnectionString %>"
SelectCommand='<%# "EXEC dbo._GetCurrentSession '" + Eval("Film_strCode") + "'" %>' />
Run Code Online (Sandbox Code Playgroud)
有什么方法可以使它工作吗?请帮我.
我需要使用javascript获取所有href链接值.我有这个代码,
<body onload="myFunction()">
<div class="pull-right">
<a class="download-link" id="download_link" href="%file_url%">Download</a>
</div>
</body>
Run Code Online (Sandbox Code Playgroud)
它显示像这样
<a class="download-link" href="http://mysite.com/download/myfiles/file1.pdf">Download</a>
<a class="download-link" href="http://mysite.com/download/myfiles/file2.docx">Download</a>
<a class="download-link" href="http://mysite.com/download/myfiles/file3.zip">Download</a>
<a class="download-link" href="http://mysite.com/download/myfiles/file4.html">Download</a>
Run Code Online (Sandbox Code Playgroud)
但如果我在下面的代码中使用了原生的javascript,则只会显示第一个项目.
<script type="text/javascript">
function myFunction()
{
var url = document.getElementById("download_link").href;
var ext = url.split('.').pop();
alert(ext);
}
</script>
Run Code Online (Sandbox Code Playgroud)
当我使用javascript显示项目时,为什么我只获得一个输出?我使用他们的文件扩展名测试了它,因为我拆分了文件.任何想法javascript上缺少什么?我只是想连续显示(提醒)项目.我的问题是,它只显示第一项.